Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数据是一级一级请求 #19

Open
caobin821651400 opened this issue Oct 18, 2017 · 19 comments
Open

数据是一级一级请求 #19

caobin821651400 opened this issue Oct 18, 2017 · 19 comments

Comments

@caobin821651400
Copy link

如果数据是一级一级请求的呢,展开收缩,全选全不选,

@shineM
Copy link
Owner

shineM commented Oct 18, 2017

点击父节点再去拉取子节点的数据吗?不是很明确你的需求,如果可以的话,描述详细一点

@caobin821651400
Copy link
Author

嗯,点击父节点请求子节点的数据,我看了下,demo里数据是一次性加载的

@shineM
Copy link
Owner

shineM commented Oct 19, 2017

直接把加载好的数据塞到父节点下面然后 treeView.expandNode() 就好了

@caobin821651400
Copy link
Author

节点的点击事件怎么暴露出来

@caobin821651400
Copy link
Author

点击事件我已近拿到了,数据怎么一级一级请求还是不太明白,请大佬能详细说下吗

@shineM
Copy link
Owner

shineM commented Oct 20, 2017

在点击事件里面请求数据啊 还是不清楚你的场景

@caobin821651400
Copy link
Author

能加QQ吗,谢谢

@caobin821651400
Copy link
Author

业务逻辑是这样,点击省去请求省下面的市,点击市去请求省下面的县。地址选择那样,数据量大,只能一层一层的请求,关于数据适配问题怎么解决

@shineM
Copy link
Owner

shineM commented Oct 20, 2017

数据请求回来了塞进去然后展开不就好了吗?你的问题是什么

@24Kshign
Copy link

24Kshign commented Dec 8, 2017

楼主你好,这边也是想实现一级一级请求
root.getChildren().get(position).setChildren(data);
这样设置第一层数据的子列表之后,按照您说的调用treeView.expandNode()这个方法,但是发现子列表收不回去了,请问这是怎么回事呢?方便留个联系方式交流一下吗

@caobin821651400
Copy link
Author

treeView.getAdapter().setOnItemClickListener(new TreeViewAdapter.OnItemClickListener() {
@OverRide
public void click(TreeNode treeNode) {
treeNode.setExpanded(!treeNode.isExpanded());
if (treeNode.isExpanded()) {
//打开节点
if (treeNode.getChildren().size() == 0) {
//第一次打开节点.需要请求次数据
code = ((ServiceAreaResp) treeNode.getValue()).getId();
child = treeNode;
tempLevel = treeNode.getLevel() + 1;
getServiceAreaData();
} else {
//第N次打开节点
treeView.expandNode(treeNode);
}
} else {
//关闭节点
treeView.collapseNode(treeNode);
}
}
}); @Jakemesdg 在关闭啊

@24Kshign
Copy link

24Kshign commented Dec 8, 2017

那请问,您是怎么把子列表的数据塞进去的呢

@24Kshign
Copy link

24Kshign commented Dec 8, 2017

我这边想的是点击的时候把position传过来然后再处理,但是后来发现position传过来的是错乱的

@shineM
Copy link
Owner

shineM commented Dec 8, 2017

parentNode.addChild()

@gwgrisk
Copy link

gwgrisk commented Feb 4, 2018

看评论就懂了,谢谢个位

@Archer-Lin
Copy link

您好,请问下节点的点击事件怎样拿到呢

@caobin821651400
Copy link
Author

treeView.getAdapter().setOnItemClickListener() @Archer-Lin

@Archer-Lin
Copy link

treeView对象没getAdapter()方法,只有getAllNodes()、getSelectedNodes()、getView()这3个方法,你是不是有封装过呢 @caobin821651400

@caobin821651400
Copy link
Author

你在TreeView中把adater返回回来就行了 public Adapter getAdapter(){return @@@@mAdapter} @Archer-Lin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants