Reputation: 4343
I have created a SearchActivity
based on a RecyclerView
that should search through an ArrayList<>
that I have declared in my MainActivity
public class SearchActivity extends ListActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
handleIntent(getIntent());
}
public void onNewIntent(Intent intent) {
setIntent(intent);
handleIntent(intent);
}
public void onListItemClick(ListView l, View v, int position, long id) {
//DA IMPLEMENTARE: chiama accordo activity
// do not care about this method, I'll implement it later
}
private void handleIntent(Intent intent) {
if(Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
doSearch(query);
}
}
private void doSearch(String queryStr) {
// I think I should implement an adapter here
}
}
I think I should implement something in the doSearch()
method, but I do not know how to do it. I'd really appreciate if you could help me out
Upvotes: 0
Views: 78
Reputation: 2954
You should use a Filter and implement Filterable on your RecyclerView Adapter. Check this link out. or check this tutorials if you dont want to use Filter method
Upvotes: 1