android.widget.SearchView cannot be cast to android.support.v7.widget.SearchView

后端 未结 9 1764
感情败类
感情败类 2020-12-05 14:46

I\'m not unsure of why I\'m getting this error. Here\'s the menu in question:



        
相关标签:
9条回答
  • 2020-12-05 15:11

    instead of using androids

    android:actionViewClass="android.widget.SearchView"
    

    you have to use the apps

    app:actionViewClass="android.widget.SearchView"
    

    as per the documentation.

    0 讨论(0)
  • 2020-12-05 15:20

    In your menu.xml your has to be

    <item
      android:id="@+id/action_search"
      android:icon="@drawable/ic_action_search"
      android:title="@string/action_search"
      android:showAsAction="collapseActionView|ifRoom"
      android:actionViewClass="android.support.v7.widget.SearchView" />
    

    with that change in the last line

    0 讨论(0)
  • 2020-12-05 15:22

    you can fixed this issue by doing this job in your code

    adding this

    import android.widget.SearchView;

    0 讨论(0)
提交回复
热议问题