android--using the ListView to implement a multilevel tree control

Source: Internet
Author: User
  1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.