hcg_21 2012-10-23 02:22 采纳率: 0%
浏览 5162
已采纳

当列表视图是空的时,如何显示空视图?

以下是我设计的布局:
不知道什么原因,即使列表都不是空的,但是视图(在这个案例中是TextView)总是出现空视图。我以为列表会自动检测到什么时候显示空视图。
如何正确检测空视图呢?

elativeLayout android:id="@+id/LinearLayoutAR"
            android:layout_height="fill_parent" android:layout_width="fill_parent">
            <ListView android:layout_width="fill_parent"
                android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
                android:id="@+id/ARListView"></ListView>
            <ProgressBar android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:id="@+id/arProgressBar"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"></ProgressBar>
            <!-- Here is the view to show if the list is emtpy -->
            <TextView android:id="@id/android:empty" android:layout_width="match_parent"
        android:layout_height="match_parent" android:text="No Results" />
        </RelativeLayout>
  • 写回答

2条回答

  • xiaoyan_12 2012-10-23 05:31
    关注

    应该是:

    <TextView android:id="@android:id/empty" android:layout_width="match_parent"
                android:layout_height="match_parent" android:text="No Results" />
    

    注意id的属性

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler