滚动一个ListView改变了一切,从白到黑 [英] Scrolling a ListView changes everything from White to Black

查看:92
本文介绍了滚动一个ListView改变了一切,从白到黑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义列表视图,我想在列表的背景是白色的,所以我不喜欢这样伟大的工程。

I have a custom list view and I want the background of the list to be white, so I do something like this which works great.

listView = (ListView) this.findViewById(R.id.listview);
listView.setBackgroundColor(Color.WHITE);

现在的问题是,当您滚动列表中的所有列表项的背景变为黑色,看起来太可怕了。

The problem is when you scroll the list the background of all the list items changes to black, which looks horrible.

我想在我的列表视图设置背景颜色为白色。当我吹的观点我也试过背景颜色设置为白色:

I tried in my list view setting the background color to white. When I inflate the view I also tried setting the background color to white:

view.setBackgroundColor(Color.WHITE);

这两个固定的滚动背景颜色的问题,但现在该项目不显示为可点击的,即使它是。我的意思是这样的的onClick仍然能正常工作,但背景不闪烁橙色,让用户知道他点击它。

Both of these fix the problem of the scrolling background color, but now the item doesn't appear to be clickable even though it is. What I mean by that is the onClick still works fine, but the background doesn't flash to orange to let the user know he clicked it.

我怎么能有一个白色的背景列表视图,即保持白色,而滚动,并执行正常的列表acitvity Orange点击背景?

How can I have a white background in a list view, that stays white while scrolling, and does the normal list acitvity orange click background?

谢谢!

推荐答案

解决的办法很简单,你还需要设置缓存的颜色提示白: setCacheColorHint(Color.WHITE)。不需要改变列表项背景色

The solution is very simple, you also need to set the cache color hint to white: setCacheColorHint(Color.WHITE). You don't need to change the list items' background color.

这篇关于滚动一个ListView改变了一切,从白到黑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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