I have problem to change the backgroud for the list view from a func
The listView receive the data from URL by JSON encdoe like that:
{"results":[
{"db_id":"6","discount":"active","db_description":"bla bla bla ","db_num":"137","db_num2":"260"},
{"db_id":"14","db_type":"discount","db_description":"blaaaaaaa","db_num":"39","db_num2":"46"},
{"db_id":"18","db_type":"discount","db_description":"blaaaaaaa","db_num":"335","db_num2":"456"},
]}
my code:
ListAdapter adapter = new SimpleAdapter(
QueueActivity.this, QueueList,
R.layout.queue_row, new String[] { TAG_ID, TAG_DESCRIPTION, TAG_NUM, TAG_NUM2, TAG_IMAGE},
new int[] { R.id.qid, R.id.description, R.id.num, R.id.num2, R.id.list_image });
setListAdapter(adapter);
onListItemClick i can simplay update the background
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
v.setBackgroundResource(R.drawable.listview_taken_background);
TextView textid = (TextView) v.findViewById(R.id.queueid);
textid.setText("NEW TEXT")
}
but i need to update the background from a func as well
how can i do it ?
for ex, the command new FuncName().execute(“2”); will set the backround resource for 2nd row to “R.drawable.listview_taken_background”
You can use
ListView.getChildAt(int index)to return yourViewat this position then edit its background.