android nested listview android nested listview android android

android nested listview


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

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);}

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.


Is what you're looking for the ExpandableListView? Of course, that's limited to only two levels of listings (but that sounds like it would work for your needs).


This sound like what you're looking for? If you're not, or if this doesn't work, I would suggest having two list views: one of, say, blog posts, and the second of comments, and an action on a blog post item takes you to the second view, populated with the relevant comments.