I am implementing a SearchView like this:
MenuItem search = menu.findItem(R.id.search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
But this gives me an inspection report
'getActionView(android.view.MenuItem)' is deprecated
Now in the docs, it is mentioned:
This method was deprecated in API level 26.0.0
Use getActionView() directly.
So I tried this:
MenuItem search = menu.findItem(R.id.search);
SearchView searchView = (SearchView) getActionView(search);
But it still gives me the deprecated message. So what is the best practice?
Try:
MenuItem search = menu.findItem(R.id.search);
SearchView searchView = (SearchView) search.getActionView();
getActionView is deprecated?
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