I got activity using searchwidget and listview. If someone is looking, all items that do not match the query should be removed, of course. Therefore, I want to delete all elements of the list and fill it with a smaller list. So I tried passing my ArrayList to a new search operation by adding it to the Bundle in the onSearchRequested method. But this method is not called when I do a search.
This is the code I received:
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sign_player); // Associate searchable configuration with the SearchView SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) findViewById(R.id.sv_sign_search_name); searchView.setSearchableInfo(searchManager .getSearchableInfo(getComponentName())); searchView.setIconifiedByDefault(false); searchView.setFocusable(false); // Get the intent, verify the action and get the query Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); Bundle bundle = intent.getBundleExtra(SearchManager.APP_DATA); player = bundle.getParcelableArrayList("players"); player = searchPlayers(query); showPlayers(); } else { initializeScreen(); } } @Override public boolean onSearchRequested() { Bundle appData = new Bundle(); appData.putParcelableArrayList("players", player); startSearch(null, false, appData, false); return true; }
source share