Ross Thomas :
Today I decide to translate my android app from Java to Kotlin ! :) But I was very surprise when I type this :
val searchItem = menu.findItem(R.id.action_search)
val searchView = MenuItemCompat.getActionView(searchItem) as SearchView
And Android Studio told me : " 'getActionView(MenuItem!):View!' is deprecated. Deprecated in Java "
So before to ask you the solution I ask to Google what is the solution and I believed I find the solution : "Use getActionView() directly."
So I modified my code like this :
val searchView = MenuItemCompat.getActionView() as SearchView
But getActionView()
is still crossed so I don't understand at all...
I will be very happy if you can help me :) Thank you !
Egor :
The Javadoc says:
Use getActionView() directly.
Hence, what you should do is:
val searchView = searchItem.getActionView() as SearchView
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=427165&siteId=1