android - How to set color for each item listView -
if send text, edittext, listview want give color. how supposed that?
could use hex-code too? tried far.
code:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); sendbutton = (button) findviewbyid(r.id.sendbtn); textbox = (edittext) findviewbyid(r.id.textbox); listview = (listview) findviewbyid(r.id.listview); arraylist<string> listviewlist = new arraylist<string>(); adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, listviewlist); listview.setadapter(adapter); sendbutton.setonclicklistener(new onclicklistener() { public void onclick(view arg0) { adapter.add("ik typte: " + textbox.gettext().tostring()); adapter.remove(textbox.gettext().tostring()); adapter.notifydatasetchanged(); } });} @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; }
you need create own adapter arrayadapter, own layout each row.
then, in adapter, can set colors each item in getview method.
Comments
Post a Comment