2016-02-28 6 views
0

Я в основном пытаюсь создать список элементов под кнопкой, которая находится на верхней части экрана. В настоящее время у меня список списков переписан с 4-мя текстами, и все это отлично работает, пока я не создаю пейзаж приложения. Это все работает, пока это портрет.Android: ListView исчезает в ландшафтном представлении

Вот моя основная деятельность

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:orientation="horizontal" > 
<Button 
    android:id="@+id/button1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:gravity="center" 
    android:text="Pull Pipeline Grid" 
    android:onClick="onClick"/> 

<ListView 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/listview" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    ></ListView> 

Вот мой row.xml это мой ListView переопределение XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="?android:attr/listPreferredItemHeight" 
android:padding="6dip" 
android:layout_alignParentBottom="true"> 

<TextView 
    android:id="@+id/textView" 
    android:layout_width="fill_parent" 
    android:layout_height="26dip" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentRight="true" 
    android:ellipsize="marquee" 
    android:singleLine="true" 
    android:text="Description" 
    android:textSize="12sp" /> 

<TextView 
    android:id="@+id/textView2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textView" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignWithParentIfMissing="true" 
    android:gravity="center_vertical" 
    android:text="Example application" 
    android:textSize="16sp" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textView2" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignWithParentIfMissing="true" 
    android:gravity="center_vertical" 
    android:text="Hello" 
    android:textSize="16sp" /> 


<TextView 
    android:id="@+id/textView4" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/textView3" 
    android:layout_alignParentRight="true" 
    android:layout_alignWithParentIfMissing="true" 
    android:gravity="center_vertical" 
    android:text="World" 
    android:textSize="16sp" /> 

Это может быть очень просто исправить , но я новичок в разработке Android, и я не понимаю, какую часть мне не хватает. Вот результат я хочу

Desired result

ответ

0

Попробуйте изменить ориентацию LinearLayout к вертикали, как это

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 
    <Button 
android:id="@+id/button1" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_gravity="center_horizontal" 
android:gravity="center" 
android:text="Pull Pipeline Grid" 
android:onClick="onClick"/> 

    <ListView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/listview" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
></ListView> 

Надеется, что это помогает. См. Дополнительные примеры ListView http://coderzpassion.com/android-listview-with-image-and-text/