Getting a SearchView with MenuItemCompat (Android)

≡放荡痞女 提交于 2019-12-04 07:22:07

i have got the same problem, i solved it by using the follow code. Be care of your namespace.`

<!-- Search, should appear as action button -->
<item
    android:id="@+id/action_search"
    android:icon="@drawable/abc_ic_search"
    share:showAsAction="ifRoom"
    share:actionViewClass="android.support.v7.widget.SearchView"
    android:title="@string/abc_searchview_description_search" />

`

For the 1st:Fixing the second one will fix this :)

For the 2nd:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto" >

Change myapp to you application namespace com.xxx.xxx

Try to copy the lib files directly from yourFolder\sdk\extras\android\support\v7\appcompat\libs I have a similar problem,but It occurs to me when i directly copy the JAR library file rather than following the android support library procedure. Try the opposite it might work for you. Kinda weird if you ask me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!