0

私のレイアウトでは、内部に 4 つのリストビューを含む線形レイアウトの 1 つに centerVertical を設定しました。それは正常に動作します。最初は各リストビューを 1 つのアイテムとして。任意のリストビューで項目をクリックすると、そのリストビューに新しい arraylist を添付します (レベル 1 メニューとレベル 2 メニューのようなものです)。コードは正常に動作しますが、レベル 2 の arraylist を使用してリストビューを更新すると、すべてのリストビューで center_Vertical プロパティが失われ、画面の上に表示されます。

これは私のレイアウトファイルです:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


  <LinearLayout
        android:id="@+id/container"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:splitMotionEvents="true">

    <ListView
        android:id="@+id/list_left"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:layout_weight="1"/>

    <ListView
        android:id="@+id/list_center1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:layout_weight="1"/>

    <ListView
        android:id="@+id/list_center2"
        android:layout_width="match_parent"
        android:layout_height="match_parent" 
        android:scrollbars="none"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:layout_weight="1"/>

    <ListView
        android:id="@+id/list_right"
        android:layout_width="match_parent"
        android:layout_height="match_parent"  
        android:scrollbars="none"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:layout_weight="1"/>
  </LinearLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:visibility="gone"
        android:text="Clear Cache"/>
</RelativeLayout>

誰かがこれで私を助けることができれば、私は非常に感謝しています。

4

2 に答える 2

0
// you don't need to relative layout try this.
<?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:orientation="vertical" >

<LinearLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:orientation="horizontal"
    android:gravity="center_vertical"
    android:splitMotionEvents="true" >

    <ListView
        android:id="@+id/list_left"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:scrollbars="none" />

    <ListView
        android:id="@+id/list_center1"
          android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:scrollbars="none" />

    <ListView
        android:id="@+id/list_center2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:scrollbars="none" />

    <ListView
        android:id="@+id/list_right"
         android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:scrollbars="none" />
</LinearLayout>

<Button
    android:id="@+id/button1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="Clear Cache"
    android:visibility="gone" />

</LinearLayout>
于 2013-09-03T03:43:42.413 に答える