Articles → Android → Filter data in arrayadapter

Filter data in arrayadapter






Sample code




<adapter_instance>.getFilter().Filter(text);









Example




String fruitlist[] = {
    "apple",
    "banana",
    "orange",
    "cherry"
};
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter < String > adapter = new ArrayAdapter < String > (this, R.layout.support_simple_spinner_dropdown_item, fruitlist);
adapter.getFilter().filter("a");
spinner.setAdapter(adapter);



Output



Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, November 13, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250