android - Change view background color into a listview -


i'm trying change background color on view component, not success

public view getview(int position, final view convertview, viewgroup parent) {     view view = convertview;     try {         if (view == null) {             layoutinflater vi = (layoutinflater) mcontext                     .getsystemservice(context.layout_inflater_service);             view = vi.inflate(r.layout.listview_accounts, null); // --clonechangerequired(list_item)         }         final account listitem = (account) mlist.get(position); // --clonechangerequired         if (listitem != null) {              int color = listitem.getcolor();              view vcolor = (view) view                     .findviewbyid(r.id.lv_account_view_color);              vcolor.setbackgroundcolor(color);             }         }     } catch (exception e) {     }     return view; } 

i can set text in textview, set color not working.

can helps me how set color? thanks

the example color used is: -16711717

edit

listview item layout:

<?xml version="1.0" encoding="utf-8"?> <!doctype linearlayout> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" >  <view     android:id="@+id/lv_account_view_color"     android:layout_width="@dimen/activity_horizontal_margin"     android:layout_height="wrap_content"     android:background="#167117" />  <textview     android:id="@+id/lv_account_tv_name"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_marginbottom="@dimen/activity_horizontal_margin"     android:layout_marginleft="@dimen/activity_horizontal_margin"     android:layout_margintop="@dimen/activity_horizontal_margin"     android:textcolor="@color/black" />  </linearlayout> 

background cannot setted in xml, it's dynamic color

try this: vcolor.setbackgroundcolor(color.parse("#yourcolorcode"));


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -