android - Customise ListView (Multiple Choices) -
i trying change text color of listview multiple choices. found many questions it, of answers propose create textview layout , allocate adapter solution. when that, checkbox disappear.
adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_multiple_choice, countries); listview.setchoicemode(listview.choice_mode_multiple); listview.setadapter(adapter); main_activity.xml
<listview android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/listview" android:scrollbarthumbvertical="@drawable/scroll" />
you can override getview method in arrayadapter , set text color this.
arrayadapter<string> list = new arrayadapter<string>(this, android.r.layout.simple_list_item_multiple_choice, countries) { @override public view getview(int position, view convertview, viewgroup parent) { view v = converteview; if(v = null) v = layoutinflater.from(youractivity.this).inflate(android.r.layout.simple_list_item_multiple_choice, null); textview tv = (textview) v.findviewbyid(android.r.id.text1); tv.settextcolor("your_color"); return v; } }; listview.setchoicemode(listview.choice_mode_multiple); listview.setadapter(adapter);
Comments
Post a Comment