以下の 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);
}
});