Hi all,

I'd like to create a ListView that, when empty, displays text indicating
that it's empty.  I've looked around the web, and found some articles, but
nothing seems to be working - Even a direct copy and paste from these
examples (one from developer.android.com) does not have the desired effect.

I've had just about every result happen to me except the intended effect.
 I've had the TextView show up instead of the ListView, even when ListView
is not empty.  I've had the TextView NOT show up when the ListView is empty.
 And now, i have both the populated ListView and the android:empty TextView
showing on the screen at the same time.

Here is my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android";
  android:id="@+id/MainPageLayout"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical" >

    <TextView android:id="@+id/text_main_instructions"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceSmall"
  android:gravity="center_vertical"
  android:paddingLeft="6dip"
  android:paddingRight="6dip"
      android:text="@string/main_instructions"
      android:layout_alignParentTop="true"/>

    <ListView android:id="@+id/android:list"
              android:layout_width="fill_parent"
  android:layout_height="fill_parent"
      android:textAppearance="?android:attr/textAppearanceMedium"
  android:gravity="center_vertical"
  android:layout_weight="1"
  android:paddingLeft="6dip"
  android:paddingRight="6dip"
              android:layout_below="@id/text_main_instructions"
              android:drawSelectorOnTop="false"/>

  <TextView android:id="@id/android:empty"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:textAppearance="?android:attr/textAppearanceMedium"
  android:gravity="center_vertical|center_horizontal"
  android:paddingLeft="6dip"
  android:paddingRight="6dip"
           android:text="@string/main_schedule_empty"
  android:layout_below="@id/text_main_instructions"/>
</LinearLayout>

Is there something i have to call in code to make this work?  What am i
doing wrong?

Also, does my ListView have to have the id "@id/android:list" in order for
this to work, or can i give it a different id?

-- 
//Nick Richardson
//richardson.n...@gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to