简体   繁体   中英

Use SearchView with android 2.3

I'm trying to use a searchView in my app and i initialized the searcView (from android.support.v7.widget) like this in the onCreateOptionsMenu method (I use android.support.v7.app.ActionBarActivity and )

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_carte, menu);
    SupportMenuItem searchItem = (SupportMenuItem) menu.findItem(R.id.menu_recherche);
    searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
    if (mSearchView != null) {
        mSearchView.setOnQueryTextListener(this);
    }
    setupSearchView(searchItem);
    return super.onCreateOptionsMenu(menu);
}

I'have not issues on android 4.4 but in android 2.3 I have this error :

Could not find class 'android.support.v7.widget.SearchView$5', referenced from method android.support.v7.widget.SearchView.addOnLayoutChangeListenerToDropDownAnchorSDK11

Thanks for your help

this problem is caused by png processor in gradle plugin. If you are using android studio change the gradle plugin to 0.9.2. This worked for me

https://code.google.com/p/android/issues/detail?id=67388

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM