How to add two listviews in a fragment in android layout?

Sarweshkumar C R

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>
jlhonora

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to add Options Menu to Fragment in Android

From Dev

Android Fragment declared in layout, how to set arguments?

From Dev

How to build a complex layout in android with multiple listviews

From Dev

Android: how to populate two different listviews with database?

From Dev

How to add tab inside fragment in android?

From Dev

Android: how to add another fragment to the main activity

From Dev

How to Sync Multiple ListViews Android

From Dev

Android display two full-size ListViews

From Dev

How to add fragment during runtime in android

From Dev

Move items between two listviews in activity in Android?

From Dev

Show 3 scrollable ListViews of equal height in Android Layout

From Dev

Add a Drawer Layout to existing Map Fragment in Android

From Dev

How to divide an Fragment in Android into Two Colors

From Dev

Android - How to add a Google Map to this fragment?

From Dev

Android - How to inflate an activity layout to fragment?

From Dev

how to add two ListViews in parallel?

From Dev

Android - How to dynamically change fragment layout

From Dev

Separate the layout to two activities, fragment

From Dev

Android - Three Listviews one Fragment; First Listview controls other two; Highlight first Listview choice

From Dev

Add listview adapter to layout of Fragment

From Dev

Add listview adapter to layout of Fragment

From Dev

Android - fragment with three listviews crashes with out of memory error

From Dev

How to Split a List into two to populate differnt listviews?

From Dev

An activity with two listviews in android

From Dev

How to make MultiPan Fragment layout in android

From Dev

Android - How to inflate an activity layout to fragment?

From Dev

How to add bundle to Android fragment

From Dev

Android Two listviews and adapters

From Dev

How to include a Layout Fragment in Android

Related Related

  1. 1

    How to add Options Menu to Fragment in Android

  2. 2

    Android Fragment declared in layout, how to set arguments?

  3. 3

    How to build a complex layout in android with multiple listviews

  4. 4

    Android: how to populate two different listviews with database?

  5. 5

    How to add tab inside fragment in android?

  6. 6

    Android: how to add another fragment to the main activity

  7. 7

    How to Sync Multiple ListViews Android

  8. 8

    Android display two full-size ListViews

  9. 9

    How to add fragment during runtime in android

  10. 10

    Move items between two listviews in activity in Android?

  11. 11

    Show 3 scrollable ListViews of equal height in Android Layout

  12. 12

    Add a Drawer Layout to existing Map Fragment in Android

  13. 13

    How to divide an Fragment in Android into Two Colors

  14. 14

    Android - How to add a Google Map to this fragment?

  15. 15

    Android - How to inflate an activity layout to fragment?

  16. 16

    how to add two ListViews in parallel?

  17. 17

    Android - How to dynamically change fragment layout

  18. 18

    Separate the layout to two activities, fragment

  19. 19

    Android - Three Listviews one Fragment; First Listview controls other two; Highlight first Listview choice

  20. 20

    Add listview adapter to layout of Fragment

  21. 21

    Add listview adapter to layout of Fragment

  22. 22

    Android - fragment with three listviews crashes with out of memory error

  23. 23

    How to Split a List into two to populate differnt listviews?

  24. 24

    An activity with two listviews in android

  25. 25

    How to make MultiPan Fragment layout in android

  26. 26

    Android - How to inflate an activity layout to fragment?

  27. 27

    How to add bundle to Android fragment

  28. 28

    Android Two listviews and adapters

  29. 29

    How to include a Layout Fragment in Android

HotTag

Archive