Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android nested 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)

like image 351
Ben Avatar asked Jun 28 '10 18:06

Ben


People also ask

How to create nested ListView in android?

You could organize your data structure to show nested data in one ListView. Or you can use this project PreOrderTreeAdapter. It is convenient to show nested data in ListView or RecyclerView. It can be used to make ListView or RecyclerView collapsible, just change the way you provide your data than notify the adapter.

Is ListView deprecated Android?

Conclusion. While the ListView is still a very capable view, for new projects, I'll strongly advise you use RecyclerView, and consider the ListView as deprecated. I can't think of any situation where the ListView is better than the RecyclerView, even if you implement your ListView with the ViewHolder pattern.

What is setAdapter in android studio?

setAdapter(new ArrayAdapter<String>(this,R. layout. drawer_list_item, mServices)); This line is mapping an array of strings ( mServices ) for display in a ListView ( mDrawerList ).

What is android ListView?

Android ListView is a view which groups several items and display them in vertical scrollable list. The list items are automatically inserted to the list using an Adapter that pulls content from a source such as an array or database.


1 Answers

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.

like image 61
Paulo Cesar Avatar answered Oct 01 '22 02:10

Paulo Cesar