android androidtreeview 清空,GitHub - Lerist/AndroidTreeView: AndroidTreeView. TreeView implementation...

AndroidTreeView

Recent changes

2D scrolling mode added, keep in mind this comes with few limitations: you won't be able not place views on right side like alignParentRight. Everything should be align left. Is not enabled by default

Description

Tree view implementation for android

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f416e64726f6964253230417273656e616c2d416e64726f696454726565566965772d627269676874677265656e2e7376673f7374796c653d666c6174

Demo

838f696d75945bca0fb6d84580b48a4f.png

Featrues

N - level expandable/collapsable tree

Custom values, views, styles for nodes

Save state after rotation

Selection mode for nodes

Dynamic add/remove node

Known Limitations

For Android 4.0 (+/- nearest version) if you have too deep view hierarchy and with tree its easily possible, your app may crash

format,png

format,png

68747470733a2f2f7777772e64726f70626f782e636f6d2f732f6e633671346a75626161753078356d2f53637265656e73686f745f323031352d30322d31352d32332d31362d35362e706e673f646c3d31

a6faeee41e71f252b7ccf2a84828f88b.png

Integration

1) Add library as a dependency to your project

compile 'com.github.bmelnychuk:atv:1.2.+'

2) Create your tree starting from root element. TreeNode.root() element will not be displayed so it doesn't require anything to be set.

TreeNode root = TreeNode.root();

Create and add your nodes (use your custom object as constructor param)

TreeNode parent = new TreeNode("MyParentNode");

TreeNode child0 = new TreeNode("ChildNode0");

TreeNode child1 = new TreeNode("ChildNode1");

parent.addChildren(child0, child1);

root.addChild(parent);

3) Add tree view to layout

AndroidTreeView tView = new AndroidTreeView(getActivity(), root);

containerView.addView(tView.getView());

The simplest but not styled tree is ready. Now you can see parent node as root of your tree

4) Custom view for nodes

Extend TreeNode.BaseNodeViewHolder and overwrite createNodeView method to prepare custom view for node:

public class MyHolder extends TreeNode.BaseNodeViewHolder {

...

@Override

public View createNodeView(TreeNode node, IconTreeItem value) {

final LayoutInflater inflater = LayoutInflater.from(context);

final View view = inflater.inflate(R.layout.layout_profile_node, null, false);

TextView tvValue = (TextView) view.findViewById(R.id.node_value);

tvValue.setText(value.text);

return view;

}

...

public static class IconTreeItem {

public int icon;

public String text;

}

}

5) Connect view holder with node

IconTreeItem nodeItem = new IconTreeItem();

TreeNode child1 = new TreeNode(nodeItem).setViewHolder(new MyHolder(mContext));

6) Consider using

TreeNode.setClickListener(TreeNodeClickListener listener);

AndroidTreeView.setDefaultViewHolder

AndroidTreeView.setDefaultNodeClickListener

...

For more details use sample application as example

Upcoming changes

1) Horizontal scroll issue

2) Add wiki?

Let me know if i missed something, appreciate your support, thanks!

Projects using this library

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值