-
Idea: repeatedly adapted to the data on the ListView;
2. Implementation method:
(1) Create a data bean (containing some attribute information);
(2) converting to tree node TreeNode (Id,parentid,bean);
(3) Build a tree with all the tree nodes including (root node and other nodes);
(4) Implementation of adapter:
1) Create two nodes list, one save list to display the node (showlist), one to save all the nodes (cache);
2) initialization is the display of the root node;
3) Each expansion and contraction is to be clicked on the node's expansion state is set to the opposite state;
4) Each expansion is a node that has all the root and parent nodes expanded into a ListView (emptying the showlist, and locating the corresponding node in the cache in the showlist);
5) in the shrinkage method, we should pay attention to the node of the contraction of the child nodes are removed from the showlist;
6) Call the Notifyondatasetchanged () method in the adapter class;
Source: http://down.51cto.com/data/1976008
android--using the ListView to implement a multilevel tree control