ListView inside another ListView

I need to make a horizontal list view inside a vertical list. Both list views can have any number of elements, and both must be scrollable.

How can I do this because I read that android does not support list hierarchy.

Thank!

Custom ui

+5
source share
4 answers

To achieve this, you need to do the following:

  • Create a vertical ScrollView having a Single LinearLayout.
  • Now create horizontal ListViews inside this Linearlayout, as shown in the example below:

, , ListView.

.

<ScrollView>  

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

: 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);
+3

ListView LinearLayout ScrollView .

ListView  - 1:   - HorizontalScrollView      - LinearLayout (: )

- /questions/1069402/how-can-i-create-a-pulse-like-ui-for-an-android-application

+1
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/ll"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical" >

 <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Accounts" />
<ListView
    android:id="@+id/Accounts"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />
<View
    android:layout_width="fill_parent"
    android:layout_height="2dp"
    android:background="#FF4500" />
<TextView
    android:id="@+id/textView1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Contacts" />
<ListView
    android:id="@+id/con_listView"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:scrollbars="vertical" />
</LinearLayout>
0

, , . () listview :)

Suppose you have a listview LV inside a Horizontal Listview HV, then you need to write the following in the touch method of the list view -

lv.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View arg0, MotionEvent arg1) {

                if(arg1.getAction() == MotionEvent.ACTION_DOWN || arg1.getAction() == MotionEvent.ACTION_MOVE)
                {
                HV.requestDisallowInterceptTouchEvent(true);

                }
                return false;
            }
        });
0
source

All Articles