'在下面的android列表适配器中,我希望根据条件动态更改元素显示中的颜色,例如,如果TAG_AMOUNT大于2,则文本视图为红色。欢迎任何帮助! (以下是基于androidhive JSON parsor)'
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);
}
});
答案 0 :(得分:1)