defacto133 / multilevelexpandableindentablelistview Goto Github PK
View Code? Open in Web Editor NEWA multi-level collapsible/expandable indentable list view for Android
License: MIT License
A multi-level collapsible/expandable indentable list view for Android
License: MIT License
Is there any way to show list already expanded when view gets loaded?
In the current implementation, list gets expanded on clicking.
mAdapter = new MyAdapter(getActivity(), new View.OnClickListener() { @Override public void onClick(View v) { int position = mRecyclerView.getChildPosition(v); mAdapter.toggleGroup(position); } }); mRecyclerView.setAdapter(mAdapter);
As you can see from the images below, when I select an unexpanded item from a list the list collapses other root items first before I can expand any children.
http://imgur.com/ZhdWimr,IfhoLDg,M6KqMUv
http://imgur.com/ZhdWimr,IfhoLDg,M6KqMUv#1
http://imgur.com/ZhdWimr,IfhoLDg,M6KqMUv#2
What I'm doing in my code is
1. creating a hashmap of all the comments with their id as the key.
2. Iterating the list of comments and finding the parent of each item
and adding the current item as a child to that parent.
3. Getting all the top level comments and adding them to the adapter.
public void loadComments(Submission detailedPost){
this.post = detailedPost;
root = TreeNode.root();
lookup = new HashMap<String,Comment>();
CommentNode commentRootNode = post.getComments();
Iterable<CommentNode> iterableComments = commentRootNode.walkTree(TraversalMethod.PRE_ORDER);
createNodeLookupMap(iterableComments);
allocateChildrenToParentNodes();
addTopLevelNodesToRoot();
}
public void createNodeLookupMap(Iterable<CommentNode> iterableComments){
for (CommentNode node : iterableComments) {
lookup.put(node.getComment().getFullName(), new Comment(node));
}
}
public void allocateChildrenToParentNodes() {
for (Map.Entry<String, Comment> entry : lookup.entrySet()) {
Comment proposedParent;
String entryParentId = entry.getValue().getCommentNode().getComment().getParentId();
if(!entryParentId.equals(post.getFullName())){
proposedParent = lookup.get(entryParentId);
if(proposedParent != null) {
proposedParent.addChild(entry.getValue());
}
}
}
}
public void addTopLevelNodesToRoot(){
List<Comment> comments = new ArrayList<Comment>();
for (Map.Entry<String, Comment> entry : lookup.entrySet()) {
// Get all the top level nodes and add them to the final list
CommentNode node = entry.getValue().getCommentNode();
if (node.isTopLevel()){
comments.add(entry.getValue());
}
}
commentsAdapter.addAll(comments);
commentsAdapter.notifyDataSetChanged();
}
Steps:
2.1
, using manual method as Android Studio
is bad in that respect.runProguard false
to minifyEnabled false
in sampleapp/build.gradle
and multilevelexpindlistview/build.gradle
ApplicationId
, so have to remove that line from multilevelexpindlistview/build.gradle
After I insert an item into the list a duplicate is popping up.
It's not necessarily the one I just inserted that is duplicated. It is usually further down the list.
Anyone else have this issue or have a fix?
by default you see all the expanded rows and I would like to change this behavior.
when i collapseGroup maybe the group of last child show ,and the group item gone .i'm sorry for my english.
One of the reasons the library is not seeing high usage is because it is hard to add to your project.
How about using jitpack:
https://jitpack.io/#defacto133/MultiLevelExpandableIndentableListView/v0.1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.