Ich versuche, ein RelativeLayout, das 2 TextViews enthält, über einem ListView als Header hinzuzufügen, habe aber Probleme. Der Code, den ich bisher haben zeigt die Listview, die Fußzeile, aber keinen Kopf:Hinzufügen von RelativeLayout über einem ListView
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- Header -->
<RelativeLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:id="@+id/headerIcon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="@+id/headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#919191"
/>
</RelativeLayout>
<!-- Header -->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="0dp"
>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView android:id="@android:id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No items"
android:padding="5dp"
/>
</LinearLayout>
<!-- Footer -->
<RelativeLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:id="@+id/footerIcon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
<TextView
android:id="@+id/footerText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="right"
/>
</RelativeLayout>
<!-- Footer -->
</RelativeLayout>
UPDATE:
Ich habe es teilweise zu arbeiten. Der folgende Code zeigt die Kopfzeile TextViews, aber wenn ich die ListView blättern, flackert und verschwindet das Kopfzeilenlayout. Warum ist das Arbeiten mit Layouts in Android so frustrierend?
Dies ist der Code, den partically funktioniert:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:id="@+id/headerIcon"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:background="#919191"
/>
<TextView
android:id="@+id/headerText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#919191"
/>
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@android:id/list" android:layout_width="fill_parent" android:layout_height="fill_parent" />
<TextView android:id="@android:id/empty"
style="@style/BaseStyle"
android:text="No keywords entered"
android:padding="5dp"
/>
</LinearLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
>
<TextView
android:id="@+id/statusUpdated"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/Status"
android:layout_alignParentLeft="true"
android:background="#919191"
/>
<TextView
android:id="@+id/statusItems"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Status"
android:layout_alignParentRight="true"
android:background="#919191"
/>
</RelativeLayout>
</RelativeLayout>