2

In my custom list activity, I have added header in my list activity, it works fine when the list is populated, when it is empty the header also gone, so is there any option to place a permanent header in the list activity.

My XML code is,

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="@drawable/background">

<ListView
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:layout_marginTop="10dip"
    android:layout_marginBottom="10dip"
    android:drawSelectorOnTop="false"
    android:cacheColorHint="@color/black"/>

<TextView
    android:id="@android:id/empty"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center_vertical"
    android:textSize="24dip"
    android:text="@string/empty"/>

ad_header.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.example.Password"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical">

<ImageView
    android:id="@+id/add"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:paddingTop="5dip"
    android:paddingBottom="5dip"
    android:src="@drawable/add_new_item"
    android:background="@color/white"/>

Thanks.

Vignesh
  • 3,571
  • 6
  • 28
  • 44

1 Answers1

3

Here is another thread related to your question Android: Adding static header to the top of a ListActivity

Community
  • 1
  • 1
ZelluX
  • 69,107
  • 19
  • 71
  • 104