【发布时间】:2018-05-30 15:50:25
【问题描述】:
我收到了这个错误
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter event
换行
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent)
以下是整个代码。此代码最初是在 java 中,我使用 Android Studio 将其转换为 Kotlin,但现在我收到此错误。我尝试重建和清理项目,但没有奏效。
val action = supportActionBar //get the actionbar
action!!.setDisplayShowCustomEnabled(true) //enable it to display a custom view in the action bar.
action.setCustomView(R.layout.search_bar)//add the custom view
action.setDisplayShowTitleEnabled(false) //hide the title
edtSearch = action.customView.findViewById(R.id.edtSearch) as EditText //the text editor
//this is a listener to do a search when the user clicks on search button
edtSearch?.setOnEditorActionListener(object : TextView.OnEditorActionListener {
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent): Boolean {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Log.e("TAG","search button pressed") //doSearch()
return true
}
return false
}
})
【问题讨论】:
标签: android kotlin illegalargumentexception