

最快的Android TreeView出现了!
source link: http://blog.csdn.net/niu_gao/article/details/78985540?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

又又又更新了!
源码地址:https://github.com/niugao/RecyclerListTreeView
版本更新到0.1.8!修正多个bug,增加多项实用功能!
- 添加从获取节点的相邻哥哥和弟弟的方法:getNextSibling(),getPrevSibling();
- 添加获取一个node在兄弟中排行的方法:getNodeRank(); 修正插入节点时的bug;
- 添加了遍历整棵树的方法forEach(),可以代替enumCheckedNodes()方法,从而去除了唯一一处涉及递归操作的地方;
- 添加了单元测试;
版本更新到0.1.9!增加多项实用功能!
- 添加获取第最大孩子的方法getFirstChild();
- 添加获取最小孩子的方法getLastChild();
- 添加获取第n个孩子的方法getNodeByRank();(名字似乎取的不好)
无缝插入广告:向大家推荐一本Android开发入门书:《Android9编程通俗演义》-清华大学出版社,京东淘宝及各大书店有售。
- 基于RecyclerView实现。
- 存储数据的结构并不是Tree,而是一个ArrayList。与所有已知的网上的实现都不一样,大家似乎都跳不出固定思维。 可以比较一下代码量,此实现比其它的少一半都不止。
- 核心是一个表示Tree的类,但它的本质是一个List。对RecyclerView没有任何改动,对Adapter只有少量封装, 使用者不会产生任何陌生感。也就是说你对RecyclerView能做的,现在依然能做。
- 以List的形式表式树,带来很多好处:
-
- 大部分情况下,消除了递归。该用递归的地方基本都变成了循环
-
- 节点有序,插入节点时,可以指定它是它爸爸的第几个儿子。
-
- 极其适合在RecyclerView中使用:与List无异,无论根节点还是子节点都对应RecyclerView中的一行,不需对RecyclerView做任何改动 。
远看像棵树
近看不是树
似树而非树
是为牛逼树
在Gradle中添加依赖:
implementation ‘com.edu:recyclerlisttreeview:0.1.8’
定义Adapter:
见示例程序。
构建Tree集合:
见示例程序。
使用Adapter:
见示例程序。
[外链图片转存失败(img-vKLKasvK-1564788158020)(https://github.com/niugao/RecyclerListTreeView/raw/master/snapshots/1.png)]
Recommend
-
148
Android TreeView is used to display data in tree structures.
-
44
The TreeView in Telerik UI for Blazor lets you control when and how each set of nodes gets loaded. That not only lets you control how the nodes are loaded but can also improve your page’s performance. The TreeView...
-
32
点击上方蓝字可直接关注!方便下次阅读。如果对你有帮助,可以点个在看,让它可以帮助到更多老铁~ 一、 概述 接着之前的话题继续! 如果把之前的QTableView改成 QTreeView ,我们在不改变...
-
28
Bootstrap 4 Tree View A very simple plugin to build a basic and elegant Treeview with boostrap 4. Dependencies
-
9
:tea: Vue Teatree A simple treeview component for VueJS with no added dependencies. Install yarn...
-
5
[GopherJS] Treeview Theory and Practice ≡ [GopherJS] Tr...
-
11
[AngularJS] Treeview May 27, 2016
-
4
Use a recursive Blazor component to render a TreeViewOctober 31, 2022 · 2 minute read · Tags: blazorI recently ran into a require...
-
7
Yahoo User Interface library (YUI2) TreeView v2.8.2 - Multiple Reflected Cross Site Scripti...
-
9
C++ Qt开发:TableView与TreeView组件联动 Qt...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK