我怎样才能在ListView中添加不同的颜色

Yas*_*pal 5 android row android-arrayadapter

我想在列表视图的每一行中获得不同的颜色

但目前只显示一种颜色

那我怎么能这样做呢

ArrayAdapter<String> adapter=new ArrayAdapter<String(this,R.layout.latesthappenings,R.id.LH_Titles,titles);
            setListAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

我想在每一行中使用不同的颜色

请告诉我该怎么办

谢谢

Din*_*rma 0

在数组中设置所有不同的颜色(列表中所需的)代码,并从该数组中为每个行位置获取颜色代码,并使用setBackgroundColor()方法将该背景颜色设置为列表行。

尝试这个。