块引用
我正在使用listview和Searchview.Below我的代码在主要活动中。
enter code here
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.searbar);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
madapter.getFilter().filter(newText);
return false;
}
});
return super.onCreateOptionsMenu(menu);
// return true;
}
块引用
但是,在代码
下运行时app不会打开enter code here
getMenuInflater().inflate(R.menu.menu_search, menu);
MenuItem item = menu.findItem(R.id.searbar);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);