我是android和java的新手。我想讓ListView呈現紅色的第三行(不是每三行)。更改ListView中某一行的文本顏色
ArrayList<String> weekInfoList = new ArrayList<>();
weekInfoList.add("first row");
weekInfoList.add("second row");
weekInfoList.add("third row");
ArrayAdapter arrayAdapter1 = new ArrayAdapter(MainActivity.this, R.layout.list_item2, weekInfoList);
weeklyListView.setAdapter(arrayAdapter1);
weeklyListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> a, View v, int position, long id) {
// intent to next activity
}
});
請幫幫我。
你應該使用recyclerview而不是 –
檢查這個答案http://stackoverflow.com/questions/13109840/android-alternate-row-colors-in-listview –