我想改变我的ListView项目的颜色(使用Async类填充),具体取决于一个变量。所以,我有这个更改android listview项目的前景色
public class Search extends AsyncTask<Void, String, Void> {
boolean blue = false;
@Override
protected Void doInBackground(Void... params) {
Resources res = getResources();
List<String> Items = Arrays.asList(res.getStringArray(R.array.Items));
for (String it : Items) {
if (it.contains("blue")) { blue = true; } else { blue = false; }
publishProgress(it);
}
return null;
}
@SuppressWarnings("unchecked")
@Override
protected void onProgressUpdate(String... item) {
((ArrayAdapter<String>)getListAdapter()).add(item[0]);
// Change the color of the current item depending on "blue"
}
}
这可能吗?谢谢!
在哪个类中,或者在哪里? – ali 2012-04-24 09:02:06
扩展BaseAdapter或其他适配器。 – 2012-04-25 03:29:37