【问题标题】:Backgroundcolor on ListView ItemsListView 项目上的背景色
【发布时间】:2013-02-12 06:46:41
【问题描述】:

我的问题:

ring5Views[i]
                .setOnItemClickListener(new AdapterView.OnItemClickListener() {

                    public void onItemClick(AdapterView<?> parent,
                            View arg1, int position, long arg3) {


            arg1.setBackgroundColor(Color.parseColor("#444444"));

                    }

                });

如果我每隔一个项目 (%2) 单击一个项目(子项),它的背景颜色就会改变。 为什么?

我想要的漏洞是一个包含项目和不同颜色的列表,但 getChild 不能解决问题,因为每次都是 NULL。而 getItem 没有帮助,因为它只返回值(字符串)

它应该是这样工作的......

for(int i=0; i<oneList;i++)
        {
            oneList.getChildAt(i).setBackgroundColor(Color.blue);
        }

谢谢

【问题讨论】:

    标签: android listview background-color


    【解决方案1】:

    扩展 ArrayAdapter 并覆盖 getView 方法。而在getView方法里面可以根据条件改变颜色

    您可以查看此Example 以供参考

    【讨论】:

      猜你喜欢
      • 2010-12-12
      • 2012-03-10
      • 2016-03-13
      • 2011-09-19
      • 1970-01-01
      • 2011-01-14
      • 2013-06-03
      • 2014-06-20
      • 1970-01-01
      相关资源
      最近更新 更多