2016-06-09 6 views
0

Ich möchte zwei Listenansicht mit meiner unteren Funktionalität in einem Layout verwenden. Hier ist meine Layoutdatei. Ich möchte nur, wenn mein Eltern Layout füllen Loch Bildschirm dann Kind kommt nach Eltern Layout und ich möchte auch zeigen meine unteren Layout, wie es ist. Bitte hilf mir, das zu lösen. Danke :)Wie kann ich zwei Listenansicht mit Schaltfläche unten verwenden

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_alignParentBottom="true" 
xmlns:android="http://schemas.android.com/apk/res/android"> 

<ListView 
    android:id="@+id/my_cart_list" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"/> 
<ListView 
    android:id="@+id/my_ecart_list" 
    android:layout_below="@+id/my_cart_list" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/rr" 
    android:layout_weight="1"/> 

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:id="@+id/rr" 
    android:background="#FA0" 
    android:layout_marginBottom="0dp"> 

    <TextView 
     android:id="@+id/item_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Items" 
     android:textColor="#000" 
     android:textSize="17sp" 
     android:layout_marginTop="15dp" 
     android:layout_marginLeft="20dp"/> 

    <TextView 
     android:id="@+id/cart_item_count" 
     android:layout_toRightOf="@+id/item_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="(2)" 
     android:textColor="#000" 
     android:textSize="17sp" 
     android:layout_marginTop="15dp" 
     android:layout_marginLeft="5dp"/> 


    <TextView 
     android:id="@+id/total_cart_amount" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="#000" 
     android:textSize="20sp" 
     android:layout_alignTop="@+id/cart_item_count" 
     android:layout_centerHorizontal="true" /> 

    <Button 
     android:id="@+id/checkout_cart" 
     android:layout_width="wrap_content" 
     android:layout_height="25dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginRight="4dp" 
     android:layout_marginTop="4dp" 
     android:padding="3dp" 
     android:text="Checkout >>" 
     android:textSize="16dp" /> 

    <TextView 
     android:id="@+id/mycart_empty" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="CART IS EMPTY" 
     android:gravity="center" 
     android:textColor="#000" 
     android:textSize="22sp" 
     android:layout_marginTop="12dp"/> 

</RelativeLayout> 
</RelativeLayout> 
+0

Verwenden Sie das Layoutgewicht-Konzept, ODER geben Sie Listview eine feste Höhe. –

+0

Ich werde Layout-Gewicht verwenden, aber mein zweites Layout wird nicht nach dem ersten kommen .. und ich möchte, dass alle Layout über dem Kind relativ Layout. –

+0

Bitte besuchen Sie diese [link] (http://stackoverflow.com/a/28713754/2078074). Hoffe, es wird dir helfen. – Lawrance

Antwort

1
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <!-- your button layout goes here --> 
    </RelativeLayout> 

</LinearLayout> 

, wenn Sie Auto wollen die Höhe Ihrer Ansicht neu einstellen (hier Listenansicht) dann stellen Sie Ihre Höhe wie 0DP und setzen Sie das Gewicht, wie Sie wollen.

EDIT: Sorry meine schlechte ich habe den Code aktualisiert.

+0

aber wo ich listview setzen kann –

+0

It'k Sir unter Xml-Code ist funktioniert für mich.Vielen Dank –

0

Besuchen Sie this.

Oder dieses Fragment kopieren:

<?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" 
    android:orientation="vertical" > 

    <ListView 
     android:id="@+id/listView1" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" > 
    </ListView> 

    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="0" 
     android:text="Button" /> 

</LinearLayout> 
0

Ersetzen Sie Ihre xml mit diesem Code.

<?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" 
    android:orientation="vertical" 
    android:weightSum="1"> 

    <ListView 
     android:id="@+id/my_ecart_list" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.45" /> 

    <ListView 
     android:id="@+id/my_cart_list" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.45" /> 

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/rr" 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="0.1" 
     android:background="#FA0"> 

     <TextView 
      android:id="@+id/item_text" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="20dp" 
      android:layout_marginTop="15dp" 
      android:text="Items" 
      android:textColor="#000" 
      android:textSize="17sp" /> 

     <TextView 
      android:id="@+id/cart_item_count" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="5dp" 
      android:layout_marginTop="15dp" 
      android:layout_toRightOf="@+id/item_text" 
      android:text="(2)" 
      android:textColor="#000" 
      android:textSize="17sp" /> 


     <TextView 
      android:id="@+id/total_cart_amount" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignTop="@+id/cart_item_count" 
      android:layout_centerHorizontal="true" 
      android:textColor="#000" 
      android:textSize="20sp" /> 

     <Button 
      android:id="@+id/checkout_cart" 
      android:layout_width="wrap_content" 
      android:layout_height="25dp" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="4dp" 
      android:layout_marginTop="4dp" 
      android:padding="3dp" 
      android:text="Checkout >>" 
      android:textSize="16dp" /> 

     <TextView 
      android:id="@+id/mycart_empty" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="12dp" 
      android:gravity="center" 
      android:text="CART IS EMPTY" 
      android:textColor="#000" 
      android:textSize="22sp" /> 

    </RelativeLayout> 


</LinearLayout> 
+0

Vielen Dank, es ist Arbeit für mich..danke so viel :) –

+0

@Yogipuranik wenn es funktioniert dann akzeptieren Sie die Antwort und vote up. –

+0

okay, Sir danke –

Verwandte Themen