Android ListView 与 Style 到元素的问题;滚动样式自动改变后
我的应用程序中有一个自定义 ListView
,它内部有一些 TextView
,在运行时向其提供样式。当我向下滚动 ListView
并再次向上滚动时,之前给 TextView
提供的样式会更改为某种不同的样式。 有什么办法可以防止这种情况发生吗?
我认为,将所有代码放在这里会使页面看起来很丑。因此,请按照以下链接获取代码 -
I have a Custom ListView
in my application and it has some TextView
s inside it to which the styles are provided at run time. When I scroll down the ListView
and again scroll up, the styles given previously to the TextView
changes to some different style.
Is there any way to prevent this?
I think, putting all the code here will make the page look ugly. So kindly follow these links for code-
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您使用自定义
适配器
吗?也许是不正确地重用convertView导致的一些问题,你能发布代码吗?或者也许只是改变背景颜色?在这种情况下很简单:
android:cacheColorHint="#00000000"
将完成这项工作。ListView
的 XML 中的Do you use custom
Adapter
? Maybe it is some issue with incorectly reusing convertView, can you post the code?Or maybe it is just changing background color? In that case simple:
android:cacheColorHint="#00000000"
in
ListView
's XML will do the work.我找到了解决它的方法。只需在“转换视图”中设置 TextView 一些默认样式,就像
在 ViewHolder 构造函数中以及在您用来将元素设置为默认状态的方法中一样。
I found a way to fix it. Just set the TextView with some default style in the "Convert View" like
in the ViewHolder constructor and in your method you use to set the elements to default state.