首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >替换碎片后,SwipeRefreshLayout消失

替换碎片后,SwipeRefreshLayout消失
EN

Stack Overflow用户
提问于 2019-06-21 22:47:13
回答 1查看 46关注 0票数 0

我有一个简单的应用程序,其中包含具有两个片段(FragmentA和FragmentB)的活动(充当主机活动)。

FragmentA中有一个SwipeRefreshLayout。当SwipeRefreshLayout刷新时,我们用FragmentB替换FragmentA。如果我们返回到FragmentA(通过按back按钮),SwipeRefreshLayout将消失。为了理解我的意思,请看下面的图片:

如何防止SwipeRefreshLayout在替换碎片后消失?我的类非常简单,我只是用FragmentB替换了FragmentA

fragment_a.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>

<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swRefresh"
    android:layout_width="match_parent" 
    android:layout_height="match_parent">

<FrameLayout android:layout_width="match_parent" 
             android:layout_height="match_parent">
    <Button
            android:id="@+id/click"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Click Me!"
            android:layout_gravity="center"/>
</FrameLayout>

</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
EN

回答 1

Stack Overflow用户

发布于 2019-06-21 23:19:06

相反,您应该在活动的xml文件中使用您的SwipeFreshLayout,该文件是两个片段的父文件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56705708

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档