'在下面的 android 列表适配器中,我希望根据条件动态更改元素显示的颜色,例如,如果 TAG_AMOUNT 大于 2,则文本视图为红色。欢迎任何帮助!(以下基于androidhive JSON解析器)'
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
AllProductsActivity.this, productsList,
R.layout.list_item, new String[] { TAG_PID,TAG_NAME, TAG_AMOUNT, TAG_LOCATION},
new int[] { R.id.pid, R.id.name, R.id.amount, R.id.location});
// updating listview
setListAdapter(adapter);
}
});