i'm trying display two listviews in a fragment. but i'm getting problems in xml file itself. I am using sherlock fragment. Also one list should be displayed on 2/3 space of the screen and another list on 1/3 of the screen space. please can u help? Any help would be appreciated. Thanks in advance.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DEF7C6"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/layout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:layout_width="60dp"
android:layout_height="35dp"
android:paddingLeft="0dp"
android:src="@drawable/search" />
<EditText
android:id="@+id/EditText01"
android:layout_width="280dp"
android:layout_height="wrap_content"
android:hint="Search"
android:paddingLeft="50dp"
android:textColor="#000000" >
</EditText>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/EditText01"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/darker_gray" >
</ListView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="#CFCACC" >
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/layout2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/layout1"
android:layout_weight="2" >
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#000000" />
</RelativeLayout>
<Button
android:id="@+id/addbutton"
android:layout_width="42dp"
android:layout_height="41dp"
android:layout_above="@+id/list"
android:layout_alignParentRight="true"
android:background="@drawable/buttonadd" />
</RelativeLayout>
Here's the code for the ListViews only:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#DEF7C6"
android:orientation="vertical" >
<ListView
android:id="@+id/list1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:drawSelectorOnTop="false"
android:entries="@array/l1"
android:listSelector="@android:color/darker_gray" >
</ListView>
<ListView
android:id="@+id/list2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:drawSelectorOnTop="false"
android:entries="@array/l2"
android:listSelector="@android:color/darker_gray" >
</ListView>
</LinearLayout>
Note the "weight" parameter to achieve the 2/3 - 1/3 proportion. You should look here if you want to add list view elements dynamically.
If you want other elements instead of the second ListView
just change it for a LinearLayout
or a RelativeLayout
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments