我怎样才能让在expandablelistview儿童持久的变化? [英] How can I make persistent changes to children in an expandablelistview?

查看:293
本文介绍了我怎样才能让在expandablelistview儿童持久的变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我一直在试图使用expandablelistview作为一个优雅的界面我的应用程序,但我不断地失败,从中提取所需的行为。当我点击一个孩子,我可以改变它的背景,不同的颜色,或者文字更改为不同的颜色,甚至改变文本本身。然而,当我周围的滚动(例如,孩子离开可视区域)或折叠/展开组,我做了什么变化频繁消失了。

So I've been trying to use an expandablelistview as an elegant interface for my application, but I continually fail to extract the needed behavior from it. When I click a child, I can change its background to a different color, or change the text to a different color, or even change the text itself. However, when I scroll around (such that the child leaves the viewable area) or collapse/expand the group, whatever change I made frequently vanishes.

那么,我该如何使这些样的变化给孩子的,让他们坚持?谢谢你。

So, how do I make those kind of changes to a child and get them to stick? Thanks.

更新:覆盖ExpandableListAdapter的getChildView()方法来进行相应的更改,以儿童观原来工作得很好(甚至无需适配器的notifyDataSetChanged()方法)。我的问题是一个愚蠢的状态switcharoo(我有他们的权利在onChildClick但向后getChildView)。

UPDATE: Overriding the ExpandableListAdapter's getChildView() method to make appropriate changes to children views turns out to work just fine (even without the adapter's notifyDataSetChanged() method). My issue was a silly state switcharoo (I had them right in onChildClick but backwards in getChildView).

推荐答案

在Android。利用催化的一个非常重要的技术,通过 convertview 的列表视图,当一个视图熄灭-screen在滚动过程中,它被放在别的地方在屏幕上的数据部分改变。它使我们从制作1000的观点,而是对那些在同一时间屏幕上的7或8。但这些观点并不方便地返回到你想要这意味着你需要指定在每个位置上发生的事情,而不是让这个隐含发生。

The listviews on android make use of a very important technique catalyzed by convertview, when a view goes off-screen during scrolling, it is put somewhere else on screen with the data parts changed. it keeps us from making 1000 views and instead about the 7 or 8 that are on the screen at a time. but these views don't conveniently return to where you want which means that you need to specify what goes at each position, rather than letting this be happened implicitly.

那么,请问该怎么兑现?做出什么样的ArrayList或列表,来保存你的颜色状态,文字国W.E.并用任意方式标记。这些(或者红色等于3,在一个字符串数组列表整数数组列表或红色=红)。然后,它很简单,在你的 getView()您指定如果ArrayList中相应的位置上说了什么,做一些事情。但你也需要调用 notifydatasetchanged()来刷新列表视图。我建议你​​把这个在一些onclicklistener或东西,因为如果它是无国界的getView(),它会被调用的很多的不必要的。

so, how does that cash out? Make an arraylist or list of any kind, to hold your color states, text states w.e. and tag these with any arbitrary method (either red equals 3 in an integer arraylist or red = "red" in a string arraylist). Then it's simple, in your getView() you specify that if the corresponding position in the arraylist says something, do something. But you also need to call notifydatasetchanged() to refresh the listview. I'd suggest you put this in some onclicklistener or something because if it's without boundaries in getView(), it's gonna get called alot unnecessarily.

下一次,你给我code和我会告诉你code或没有人会希望能帮助你。这个被问的很多的不必要的。

Next time, you show me code and i'll show you code or no one will want to help you. this gets asked alot unnecessarily.

这篇关于我怎样才能让在expandablelistview儿童持久的变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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