创建自定义布局/更新的ListView(背景) [英] Create/update ListView with custom layout (background)

查看:158
本文介绍了创建自定义布局/更新的ListView(背景)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题的列表视图中的研究背景从FUNC更改

I have problem to change the backgroud for the list view from a func

在ListView通过JSON encdoe像接收URL数据:

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"},
]}

我的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我可以通过Simplay更新背景

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")
}

但我需要更新从FUNC背景,以及
我该怎么办呢?

but i need to update the background from a func as well how can i do it ?

为前,命令的新FUNCNAME()执行(2); 将设置底色资源,第二排为R.drawable.listview_taken_background

for ex, the command new FuncName().execute("2"); will set the backround resource for 2nd row to "R.drawable.listview_taken_background"

推荐答案

您可以使用 ListView.getChildAt(INT指数)来回报您的查看在这个位置,然后编辑它的背景。

You can use ListView.getChildAt(int index) to return your View at this position then edit its background.

这篇关于创建自定义布局/更新的ListView(背景)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆