Try something like this:
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ListView android:id="@+id/listview1"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
<LinearLayout android:layout_weight="1"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
<ListView android:id="@+id/listview2"
android:layout_height="fill_parent"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
</LinearLayout>
Where 2 LinearLayout
's will have weight 1.
And from code behind:
ListView ls1,ls2;
String colors[] = {"Red","Blue","White","Yellow","Black", "Green","Purple","Orange","Grey"};
private String phones[] = {"Android", "Blackberry", "iPhone","Windows Phone"};
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ls1 = (ListView) findViewById (R.id.listview1);
ls2 = (ListView) findViewById (R.id.listview2);
ls1.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, colors));
ls2.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, phones));
}