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 !
The Javadoc says:
Use getActionView() directly.
Hence, what you should do is:
val searchView = searchItem.getActionView() as SearchView
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With