Listview - empty list view doesn't show up

  • Replies:3
Bruno Apfelsini
  • Forum posts: 10

Jun 30, 2013, 8:27:41 PM via Website

Hi B)

My listview ist empty but it didn't show the empty list button?
What's wrong with it?

1<RelativeLayout ..."
2 xmlns:tools="..."
3 android:layout_width="match_parent"
4 android:layout_height="match_parent"
5 android:paddingBottom="@dimen/activity_vertical_margin"
6 android:paddingLeft="@dimen/activity_horizontal_margin"
7 android:paddingRight="@dimen/activity_horizontal_margin"
8 android:paddingTop="@dimen/activity_vertical_margin"
9 tools:context=".ListActivity" >
10
11 <ListView android:id="@id/android:list"
12android:layout_width="match_parent"
13android:layout_height="match_parent"
14android:background="#000fff"
15 />
16
17 <LinearLayout
18 android:id="@id/android:empty"
19 android:layout_width="fill_parent"
20 android:layout_height="fill_parent"
21 >
22 <Button
23 android:layout_width="match_parent"
24 android:layout_height="match_parent"
25 android:text="@string/click"
26 android:onClick="onClick"
27 />
28 </LinearLayout>

— modified on Jun 30, 2013, 8:32:34 PM

Reply
James Liu
  • Forum posts: 15

Jul 1, 2013, 7:37:14 AM via Website

I think because you are using RelativeLayout, and your LinearLayout doesn't specify the position related to RelativeLayout. You'd better to specify the position with alignParentLeft or alignParentRight

Reply
Bruno Apfelsini
  • Forum posts: 10

Jul 2, 2013, 9:03:17 PM via Website

It doesn't work anyway :(

Have changed it to a easier example and is not working also

1<RelativeLayout xmlns:...
2 xmlns:tools= ...
3 android:id="@+id/RelativeLayout1"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 android:orientation="vertical"
7 android:paddingBottom="@dimen/activity_vertical_margin"
8 android:paddingLeft="@dimen/activity_horizontal_margin"
9 android:paddingRight="@dimen/activity_horizontal_margin"
10 android:paddingTop="@dimen/activity_vertical_margin"
11 tools:context=".ListActivity" >
12
13 <ListView
14 android:id="@id/android:list"
15 android:layout_width="match_parent"
16 android:layout_height="match_parent"
17 android:layout_alignParentLeft="true"
18 android:layout_alignParentTop="true"
19 android:background="#000fff"
20 android:text="No data" />
21 <TextView
22android:id="@+id/android:empty"
23android:layout_width="match_parent"
24android:layout_height="match_parent"
25android:layout_alignParentLeft="true"
26 android:layout_alignParentTop="true"
27android:text="empty"/>
28
29
30
31</RelativeLayout>

Can I check wether the listview is really empty? in order to see if there is maybe another bug?

— modified on Jul 2, 2013, 9:03:53 PM

Reply
Bruno Apfelsini
  • Forum posts: 10

Jul 10, 2013, 4:31:17 PM via Website

The simple example works now - but I have solved the problem the other way round

if listview.getchildcount()==0 then {alertdialog}

It fits for me

— modified on Jul 10, 2013, 5:32:22 PM

Reply