filter - android spinner for list and "All" option -


i have android spinner works filter product listview. spinner adapter has list of brand class objects. listview shows products selected brand. need add top of list special option "all" turns off filter , shows products.

i have implemented adapter creation of fake brand class instance can add brand arraylist used adapter not ideal - other objects valid database objects ask better approach how achieve that. thanks

the way doing in apps equal. add all item first item spinner adapter , in onitemclick can :

mspinner.setonitemselectedlistener(new onitemselectedlistener() {         @override         public void onitemselected(adapterview<?> parentview, view selecteditemview, int position, long id) {                      if(position == 0){                           // show products                     } else {                           // show selected brand's products                     }         }          @override         public void onnothingselected(adapterview<?> parentview) {          }     }); 

the best option had during development one. didn't saw other way achieve this.


Comments