支持Android V4 SwipeRefreshLayout空视图问题 [英] Android support v4 SwipeRefreshLayout empty view issue

查看:621
本文介绍了支持Android V4 SwipeRefreshLayout空视图问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SwipeRefresh没有设定一个空视图列表视图这是一个SwipeRefresh布局中唯一的孩子后工作。如何解决这个问题呢?

SwipeRefresh is not working after setting an empty view for listview which is the only child of a SwipeRefresh layout. How to solve this issue?

推荐答案

下面是解决方案: 你可以简单地使用这个视图层次:

Here is the solution: You can simply use this view hierarchy :

    <FrameLayout ...>

        <android.support.v4.widget.SwipeRefreshLayout ...>

            <ListView
                android:id="@android:id/list" ... />
        </android.support.v4.widget.SwipeRefreshLayout>

        <TextView
            android:id="@android:id/empty" ...
            android:text="@string/empty_list"/>
    </FrameLayout>

然后,在code,你只需要调用:

Then, in code, you just call:

_listView.setEmptyView(findViewById(android.R.id.empty));

就是这样。

这篇关于支持Android V4 SwipeRefreshLayout空视图问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆