Ok, to simplify things, let's say I'm doing a CommentActivity in which all comments are displayed in a threaded-like fashion.
What I mean is that selecting a comment can collapse (and expand) all of its replies. This works for any level of the comment.
I tried using ExplandableList but unfortunately this only works for 2 levels.
Now I basically have a LinearLayout that contains 2 things:
- the comment in collapsed mode (originally set to invisible) - the comme开发者_JAVA百科nt in expanded mode (visible) which contains... .... - another LinearLayout which will contain any replies to that comment.This works kind of in a recursive way... It is just a matter of changing the visibility of each view between one and another to collapse and expand the comment and its replies. It works, but veeeery slowly. The time that passes from the click until the actual collapse/expansion is between 2 or 3 seconds. I suppose this is because of the complex layout of each commentm which is not that simple (they have backgrounds, images, etc etc), and sometimes there are up to 4 levels of comments.
In the ExpandableList this was done very fast. How can I achieve this performance in a multi-level list?
Instead of preloading all the comments, you should use a LayoutInflater
, to inflate the required next part when it's needed.
See: http://developer.android.com/reference/android/view/LayoutInflater.html
精彩评论