tags:

views:

65

answers:

2

Hi Everybody,

I want to use two list view in one ListActivity. How can I do this? Please help me to create two different list view in one ListActivity.

Thanks Deepak

+2  A: 

Just create an XML named main.xml file like:

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:orientation="vertical"
  android:layout_height="fill_parent"
  >
    <ListView android:id="@+id/ListView01" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        />
    <ListView android:id="@+id/ListView02" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:layout_below="@+id/ListView01"
        android:gravity="center_horizontal"
        />
</RelativeLayout>

Load this xml file via: setContentView(R.layout.main); in your onCreate function.

ListView list1 = ((ListView) findViewById(R.id.ListView01));

allows you to access the first list and then you can apply your adapter to list1. By exchanging 1 to 2 you can access the second ListView as well.

Christian
A: 

hi, I tried this but it not working .Let me know anyother way.

Regards, Lakshmanan

Lakshmanan