我有问题从func
更改列表视图的背景listView通过JSON encdoe从URL接收数据:
{"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"},
]}
我的代码:
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我可以简化更新背景
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")
}
但我也需要从func更新背景 我怎么能这样做?
对于ex,命令 new FuncName()。execute(“2”); 会将第二行的背景资源设置为“R.drawable.listview_taken_background”
答案 0 :(得分:1)
您可以使用ListView.getChildAt(int index)
在此位置返回View
,然后修改其背景。