有没有办法在Android上创建一个可扩展的列表视图,来自4个单独的列表?
例如我有:
String [] titles = "Bob", "Anna", "Georgia";
String [] phones = "123456678", "2310521010" , "98745632123";
String [] sites = "www.google.com", "www.yahoo.com", "www.etc.com";
String [] address = "Here", "there", "away";
我希望可扩展Listview的父级是标题[1],子级:电话[1],网站[1]等。 我试过了,我把这些名字用了这个:
names = Arrays.asList(titles);
但我无法添加孩子。我想做的是这样的事情:
for (int i = 0; i < 100; i++){
inMyExpandableView.put(phones(i),sites(i),address(i));
有可能吗?
感谢&#39; S
答案 0 :(得分:0)
首先,使用循环器视图而不是列表视图。
程序如下:
使用Parent元素为Recycler视图充气。
单击父项中的每个项目,在Recycler视图适配器中添加相关的子项。
在适配器中调用notifyDataSetChanged API或等效的API。
希望这对你有所帮助!
答案 1 :(得分:0)
使用this tutorial/library查看包含父/子项目的可扩展回收站视图。我已经实现了它,它的效果非常好。