Android set listItem background colour from String Array

后端 未结 3 1116
故里飘歌
故里飘歌 2021-01-24 05:37

Does anyone know how to programatically set the background of a list item from a String Array? I have two string arrays one is the title for the text view and the other contain

3条回答
  •  深忆病人
    2021-01-24 06:09

    This is what i have done for 2 colors.

    i have kept 2 colors string in color.xml and i have used it in the custom adapter of the listview

    if (position % 2 == 0)
    
                convertView.setBackgroundResource(R.color.color1);
            else
                convertView.setBackgroundResource(R.color.color2);
    

提交回复
热议问题