简体   繁体   中英

Android Custom TreeView with non-standard behavior

One of my tasks in application development is to display the directory tree. In my case it is the tree of goods and services. I see several ways to solve this problem:

  • The contents of each folder are displayed in separate Activity, as
    is done in the file manager. (this method is not for us)

  • Try to implement TreeView by inserting ExpandableListView into each other to obtain a higher level of nesting. Or use and improve ready-made solutions, such as this:

    https://github.com/Polidea/tree-view-list-android

  • Develop with a clean slate.

Additional difficulty in development it's non-standard behavior of view that I have invented. The essence of the following:

  • When you click on a list item catalog this element rises to the top of the screen and pinned in the header (see the figure).

  • A list item that stood next, fixed at the bottom of the screen (footer).

  • All the empty space between these items takes the contents of the directory, which we chose. At the same time, this content can be to scroll. Attached top and bottom list items should remain in place.

  • Directory inside may also contain a directory. When we choosing child directory all the above steps are repeated for him.

In connection with the above, I would appreciate if you send in the right direction and advise which approach to choose to develop and effectively progressed in the right direction :). Thank you.

my tree: http://i.stack.imgur.com/uhpEn.jpg

You could use an Tree View for this.
Here's a short guide how we did it:

  • Create a Tree View and let it use an internal ListView as single child.
  • Create a TreeObject class, that stores the expanded state and has references to parents and children.
  • on each click on the listview update the state of the clicked treeobject and filter the list contents to only contain the "visible" elements.
  • implement the ListViewAdapter to handle this, and write a getView() method that shows the handles, and does the necessary indentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM