PDA

View Full Version : How to change the background color of 3 first rows of a control listview



omarch
09-14-2011, 11:16 AM
Hello,I'm Current creating at aplication Android (Version 2.1), the problem it's can not
change the background color of 3 first rows of a control listview.


This my code:


//Here create CURSOR QUERY "curValores" in SQLITE
SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this,
R.layout.list_resultado, curValores, colsValores, toValores);
ListView lv1=(ListView)findViewById(R.id.ListValores);
lv1.setAdapter(mAdapter);

//Here change background color
for (int i=0; i < lv1.getCount(); i++)
{
final View row = lv1.getAdapter().getView(i,null,null);
//Condition for only change background for 3 first rows.
if (i<3)
{
row.setBackgroundColor(Color.BLUE);
}
}


//------------
This code have not error, but not change background color, you can help me?


Thanks
@omarch (twitter)