SwipeRefreshLayout的坑

不知道打家在用SwipeRefreshLayout来做下拉刷新时有没有遇到过这么个情况:在需要在列表没有数据时显示个提示,有数据时显示数据。别看很简单,然而SwipeRefreshLayout并不让你简单。。。她不许你放两个控件切换啊啊啊啊啊啊啊啊!!!!!!!好吧,还是得再加个布局容器,以下是我目前验证了各个用法后得到方法:

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipeRefresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:visibility="@{dataNull ? View.INVISIBLE:View.VISIBLE}"
            android:paddingEnd="10dp"
            android:paddingStart="10dp"
            android:overScrollMode="never"
            android:adapter="@{adapter}"
            app:layoutManager="android.support.v7.widget.LinearLayoutManager"
            />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:visibility="@{dataNull ? View.VISIBLE:View.INVISIBLE}"
            android:textColor="#80000000"
            android:textSize="20sp"
            android:text="@string/record_null_txt"/>
    </FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>

这样才能完美的实现,没有数据时可以给个提示,还可以刷新一下,有数据时就显示数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值