Actionbarsherlock searchview: setOnQueryTextListener

后端 未结 4 1734
庸人自扰
庸人自扰 2021-01-07 00:12

I\'m trying to make a filter in a List using ActionBarSherlock\'s search view. The code I currently have is the following:

@Override
public boolean onCreateO         


        
4条回答
  •  渐次进展
    2021-01-07 01:14

    Is that your full code? Right now in the onCreateOptionsMenu you create a SearchView and assign to it a OnQueryTextListener but that is all you do with it. I don't see in your code where you add this SearchView to the inflated menu.

    As you say you see the widget on the screen, I'm assuming you have declared the widget in the R.menu.building_search file, in which case you should look for that widget(which doesn't have a listener set on it so no action is performed) and not declare a new one(which will not interact with the user):

    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
    

    (This is from the Search guide on the android developer site, if I'm not mistaken this should work for ActionBarSherlock as well).

提交回复
热议问题