how to customize listview row android

前端 未结 3 784
后悔当初
后悔当初 2020-11-27 22:16

i have a names list and i want to change the color to the rows depending on the letter the name starts with. This is what i\'m using to show the ListView:

ma

3条回答
  •  死守一世寂寞
    2020-11-27 22:36

    Your problem is that, you are sending as a parameter to the function setText, a number (int) and not a String. Hence, instead of:

    holder.text2.setText(words.indexOf(position));
    

    Try this:

    holder.text2.setText("" + words.indexOf(position));
    

    Good Luck!

提交回复
热议问题