SearchView getActionView returning null
I had the same problem because in my menu I used:
android:actionViewClass="android.widget.SearchView"
as per the google documentation.
Well it turns out that if I'm using AppCompatActivity I should use
app:actionViewClass="android.widget.SearchView"
instead.
Hope this helps someone.
If you're using proguard this is the possible answer: https://code.google.com/p/android/issues/detail?id=58508
In short, add below line to your proguard config file proguard-rules.pro
.
-keep class android.support.v7.widget.SearchView { *; }
Today I had the same problem and I think I solved it. It turns out I did couple of things that were not exactly as per the ActionBarCompat
contract:
- Each activity that uses the
ActionBarCompat
should extendActionBarActivity
instead ofFragmentActivity
directly - Each activity that uses the
ActionBarCompat
should declare its theme as inheriting from theActionBarCompat
themes.
Both of those I found watching the explanation video from Google.
Now my searchView
is not null
anymore.