Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ListView inside another ListView

I've to make a horizontal list view inside a vertical list view. Both list views can have any number of elements and both needs to be scrollable.

How will I achieve this because I've read that android doesn't support list view hierarchy.

Thanks !

CUSTOM UI

like image 705
Gaurav Arora Avatar asked Jul 30 '12 12:07

Gaurav Arora


People also ask

What is shrinkWrap flutter?

Shrink wrapping the content of the scroll view is significantly more expensive than expanding to the maximum allowed size because the content can expand and contract during scrolling, which means the size of the scroll view needs to be recomputed whenever the scroll position changes.

How do I create a horizontal ListView builder in flutter?

You might want to create a list that scrolls horizontally rather than vertically. The ListView widget supports horizontal lists. Use the standard ListView constructor, passing in a horizontal scrollDirection , which overrides the default vertical direction.


1 Answers

To Achieve this this, You have to do the following::

  1. Create a Vertical ScrollView having Single LinearLayout.
  2. Now Create Horizontal ListViews inside this Linearlayout as shown in the Example below:

Hence this will let you scroll vertically in the Screen as well as Horizontally in each ListView.

for eg.

<ScrollView>  

  <LinearLayout.....  //this a vertically oriented layout
  >  
     <ListView/>  
     .
     .//This listViews Are Horizontal
     .
     <ListView>
  </Linearlayout>
</ScrollView>    

Edit: Adding Dynamically ListView to the LinearLayout.

LinearLayout ll=(LinearLayout)findViewById(R.id.id_given_in_the_XML_file);  
ListView lv=new ListView(Activityname.this);  
.
.
.
Do All ListView Processing Here
.
.
.
lv.setAdapater(adapter);  

ll.addView(lv);
like image 101
Haresh Chaudhary Avatar answered Sep 22 '22 14:09

Haresh Chaudhary