How to set the color of the first column of a Listview item? -


i have listview (shown in alertdialog) composed 2 columns, made hashmap (got idea somewhere here). each column textview. works well.

now want change textcolor of first column of given row, have no idea on how pick , set this... googled hours! clues??

this code (lists sortedset):

public void showlistdesc () {     listview listview = new listview(this);     listview.setlayoutparams(new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content));     listview.setsoundeffectsenabled(true);     listview.setselector(r.drawable.selector);      integer i=0, pos = 0;     arraylist<hashmap<string, string>> mylist = new arraylist<hashmap<string, string>>();     hashmap<string, string> map;     (string l : lists) {         if (l.equals(currlist)) pos = i;         i++;         map = new hashmap<string, string>();         map.put("list", l);         map.put("desc", getlistdesc(l, false));         mylist.add(map);     }      listview.setadapter(new simpleadapter(this, mylist, r.layout.lists_row,                 new string[] {"list", "desc"}, new int[] {r.id.list1, r.id.desc1}));      alertdialog.builder builder = new alertdialog.builder(aveactivity.this)             .setview(listview)             .seticon(r.drawable.ic_launcher)             .settitle(lists.size() + " bird lists in databases");      final alertdialog dial = builder.create();      //scrolls listview position @ top     listview.setselection(pos);      dial.show(); } 

thanks!

edit

tried extend simpleadapter following code, , can see solid black rows:

public class mysimpleadapter extends simpleadapter { private context context;  public mysimpleadapter(context context,list<? extends map<string, ?>> data,         int resource, string[] from, int[] to) {     super(context, data, resource, from, to);     this.context = context; }  @override public view getview(int position, view convertview, viewgroup parent) {     view v = convertview;     if (v == null) {         layoutinflater inflater = (layoutinflater) this.context                 .getsystemservice(context.layout_inflater_service);         v = inflater.inflate(r.layout.lists_row, null);     }      textview list1 = ((textview) v.findviewbyid(r.id.list1));     textview desc1 = ((textview) v.findviewbyid(r.id.desc1));      if (v.ispressed()) {         v.setbackgroundcolor(context.getresources().getcolor(r.color.pressed));         list1.settypeface(null, 1);         list1.settextcolor(context.getresources().getcolor(r.color.selected));     } else {         v.setbackgroundcolor(context.getresources().getcolor(r.color.black));         if (v.isselected()) {             list1.settypeface(null, 1);             list1.settextcolor(context.getresources().getcolor(r.color.checked));             desc1.settextcolor(context.getresources().getcolor(r.color.white));         } else {             list1.settypeface(null, 0);             list1.settextcolor(context.getresources().getcolor(r.color.normal));             desc1.settextcolor(context.getresources().getcolor(r.color.lesswhite));         }     }      return v; } } 

now have special requirement, no longer simple, can't use simpleadapter achieve effect asking. have extend baseadapter , in getview() method can following:

if (position == 0) {     convertview.setbackground(color1); } else {     convertview.setbackground(color2);         } 

or if want header, can use listview.addheaderview() without hassle.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -