android - how to programmatically add ToggleButton to specific listView -
i know how add togglebutton of listview rows. how add togglebutton 1 specific listview row?
im populating listview arrayadapter so
listview mlistview = (listview) findviewbyid(r.id.listviewsetting); mlistview.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, new string[] {"rate @me app", "feedback", "block", "terms of service", "push notifications", "sign out"}));
- create layout file containing togglebutton
- create customadapter extending adapter e.g. arrayadapter
- override getview() method
- implement viewholder pattern improve performance
- add logic getview() method handle togglebutton
here pseudocode
@override public view getview(final int position, final view convertview, final viewgroup parent) { // inflation here, use viewholder pattern improve performance // add logic handle togglebutton, view being togglebutton if(items.get(position).equals(something){ view.setvisibilty(view.visible); }else{ view.setvisibilty(view.gone); } }
Comments
Post a Comment