Android的嵌套的ListView [英] android nested listview

查看:152
本文介绍了Android的嵌套的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能/最好有一个嵌套的ListView?

is it possible/advisable to have a nested listview?

即。即所包含的行的另一个列表视图?

i.e. a listView that's contained within a row of another listview?

一个例子是,我的主要列表显示的博客文章,然后在每一行中,你必须为每个文章的评论另一个列表视图(这将是可折叠)

an example would be where my main list is displaying blog posts, and then in each row, you'd have another list view for the comments for each post (that would be collapsible)

推荐答案

今天我有同样的问题,所以这是我做过什么来解决这个问题:

I had the same problem today, so this is what I did to solve it:

我有一个ListView,具有CustomAdapter,并在customAdapter的getView,我有这样的事情:

I have a ListView, with a CustomAdapter, and on the getView of the customAdapter, I have something like this:

LinearLayout list = (LinearLayout) myView.findViewById(R.id.list_musics);
list.removeAllViews();

for (Music music : albums.get(position).musics) {
    View line = li.inflate(R.layout.inside_row, null);

    /* nested list's stuff */

    list.addView(line);
}

所以,恢复,这是不可能的巢列表视图,但您可以创建使用的LinearLayout和code填充它一个行内的清单。

So, resuming, It's not possible to nest to ListViews, but you can create a list inside a row using LinearLayout and populating it with code.

这篇关于Android的嵌套的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆