Monday 7 October 2013

Android ListView With Alternet ListItem Background Color

Android ListView
  1. In Android ListView we can set background color or background image of an ListItem.
  2. Today we show you how to set background color of an alternate ListView Items.
  3. Also we show you how to set alternate background image of an ListView.
  4. For that you need to understand Simple ListView so first check out our previous posts of ListView download sample source and then modify as per below code.You can find Simple ListView Posts Here
  5. After understanding previous post need to modify code as per below
  6. Look at the getView method of FruitsArrayAdapter.java and write before return rowView write below code.
 if (position % 2 == 0)  
 {  
      rowView.setBackgroundColor(Color.parseColor("#EA5B61"));  
 } else {  
      rowView.setBackgroundColor(Color.parseColor("#DC6BAD"));  
 }  

No comments:

Post a Comment