jjzjj

android - SwipeRefreshLayout Got Action_Move 卡住 View

coder 2023-12-19 原文

我有一个带有不同 fragment 的普通 NavigationDrawer :

  • 新闻
  • 其他内容 1
  • 其他资料 2
  • 设置

问题:

NewsFragment 包含一个 SwipeRefreshLayout。我第一次刷新时效果很好。

我可以将 fragment 更改为其他内容 1 和 2 以及设置。所以我回到 NewsFragment。

现在,当我刷新时, fragment 会卡住。

drawerLayout 工作正常(打开/关闭,甚至 ActionBar Title 更改)但主要 fragment 留在 NewsFragment 中,我无法滚动。但是 scollListner 可以工作(我有日志)但是 View 没有改变。

没有 refreshView(swipeRefreshLayout 的顶部),没有滚动,没有响应按钮(在焦点上,onclick),但只有视觉。

实际上,它就像一个 Responding Fragment 在卡住的 fragment 后面。

我在 ADBLog 中也有这个错误:

SwipeRefreshLayout﹕ Got ACTION_MOVE event but don't have an active pointer id.

有什么想法吗??

如果你问,我可以贴出代码。

最佳答案

好的,我找到了解决方案。我发布它是因为它可能发生在每个人身上,这有点无聊(对我来说需要两天时间)。

首先,我在包含 SwipeRefreshLayout(一个 fragment )的 XML 中有这个:

<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/news_container_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp"
android:background="@color/news_background">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/news_list_recycle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:dividerHeight="5dp" />


    <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/news_progress"
        android:visibility="invisible"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />


</RelativeLayout>

因此,要修复该错误,您需要在您的 SWIPEREFRESHLAYOUT 中安装 RECYCLEVIEW(或 ListView ):

所以,我移动我的 progressBar 并将 RelativeLayout 作为 rootView。

结果:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/news_progress"
    android:visibility="invisible"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" />

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/news_container_refresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="5dp"
    android:background="@color/news_background">


    <android.support.v7.widget.RecyclerView
        android:id="@+id/news_list_recycle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:dividerHeight="5dp" />

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

我希望它能对以后的其他人有所帮助。

关于android - SwipeRefreshLayout Got Action_Move 卡住 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26973679/

有关android - SwipeRefreshLayout Got Action_Move 卡住 View的更多相关文章

随机推荐