| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
chongchuan
8年前发布

Android开源:TreeView-利用 RecyclerView 打造高性能树形控件

   <h2>TreeView</h2>    <p>An android tree view with high performance and rich functions</p>    <h3>Captures</h3>    <p>There are some gifs from Demo:</p>    <ul>     <li>Select node:</li>    </ul>    <p style="text-align:center"><img src="https://simg.open-open.com/show/6be9434c6ad1e0b3a89728ed2b382c12.gif"></p>    <ul>     <li>Operate all:</li>    </ul>    <p style="text-align:center"><img src="https://simg.open-open.com/show/8f8d3be75cfd7ed61644d72cc4c74e2d.gif"></p>    <h3>Features</h3>    <ul>     <li>expandAll/collapseAll</li>     <li>expandNode/collapseNode</li>     <li>expandLevel/collapseLevel</li>     <li>toggleNode</li>     <li>deleteNode/addNode</li>     <li>selectNode/deselectNode</li>     <li>selectAll/deselectAll</li>     <li>getAllSelectedNodes</li>    </ul>    <h3>Usage</h3>    <p>1.Reference the library from your module's build.gradle:</p>    <pre>  <code class="language-java">compile 'me.texy.treeview:treeview_lib:1.0.2'</code></pre>    <p>2.Implement your all level's BaseNodeViewBinder</p>    <p>Sample:</p>    <pre>  <code class="language-java">public class FirstLevelNodeViewBinder extends BaseNodeViewBinder {    TextView textView;    public FirstLevelNodeViewBinder(View itemView) {       super(itemView);        textView = (TextView) view.findViewById(R.id.node_name_view)    }        @Override    public int getLayoutId() {      return R.layout.item_first_level;    }        @Override    public void bindView(TreeNode treeNode) {      textView.setText(treeNode.getValue().toString());    }  }    SecondLevelNodeViewBinder  ThirdLevelNodeViewBinder  .  .  .</code></pre>    <p>If you want add the selectable feature,replace BaseNodeViewBinder with CheckableNodeViewBinder.</p>    <p>3.Implement the BaseNodeViewFactory</p>    <p>Sample:</p>    <pre>  <code class="language-java">public class MyNodeViewFactory extends BaseNodeViewFactory {    @Override    public BaseNodeViewBinder getNodeViewBinder(View view, int level) {      switch (level) {        case 0:          return new FirstLevelNodeViewBinder(view);        case 1:          return new SecondLevelNodeViewBinder(view);        case 2:          return new ThirdLevelNodeViewBinder(view);        default:          return null;      }    }  }</code></pre>    <p>If you do not want to create a class file,just implement a anonymous inner class in TreeView's constructor</p>    <p>4.Add TreeView to wherever you want</p>    <p>Sample:</p>    <pre>  <code class="language-java">TreeNode root = TreeNode.root();  //build the tree as you want  for (int i = 0; i < 5; i++) {    TreeNode treeNode = new TreeNode(new String("Child " + "No." + i));    treeNode.setLevel(0);    root.addChild(treeNode);  }  View treeView = new TreeView(root, context, new MyNodeViewFactory()).getView();  //add to view group where you want </code></pre>    <h3>License</h3>    <p>Copyright 2017 shineM.</p>    <pre>  <code class="language-java">Licensed under the Apache License, Version 2.0 (the "License");  you may not use this file except in compliance with the License.  You may obtain a copy of the License at       http://www.apache.org/licenses/LICENSE-2.0    Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions and  limitations under the License.</code></pre>    <p> </p>    <p>项目主页:<a href="http://www.open-open.com/lib/view/home/1493797636827">http://www.open-open.com/lib/view/home/1493797636827</a></p>    <p> </p>    
 本文由用户 chongchuan 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1493797636827.html
高性能 Android开发 移动开发 RecyclerView