Coc*_*ico 4 android android-fragments navigation-drawer drawerlayout swiperefreshlayout
我有一个普通的NavigationDrawer与不同的片段:
问题 :
NewsFragment包含SwipeRefreshLayout.它第一次刷新时效果很好.
我可以将片段更改为其他东西1和2以及设置.所以我回到NewsFragment.
现在,当我刷新时,片段会冻结.
drawerLayout正常工作(打开/关闭,甚至ActionBar标题更改),但主片段保留在NewsFragment,我无法滚动.但scollListner工作(我有日志),但视图不会改变.
没有refreshView(swipeRefreshLayout的顶部),没有滚动,没有响应按钮(在焦点上,onclick)但只是在视觉上.
实际上,它就像一个响应片段在冷冻片段后面.
我在ADBLog中也有这个错误:
SwipeRefreshLayout? Got ACTION_MOVE event but don't have an active pointer id.
Run Code Online (Sandbox Code Playgroud)
任何的想法 ??
如果你问,我可以发布代码.
Coc*_*ico 11
好的,我找到了解决方案.我发布它是因为它可能发生在每个人身上,这有点无聊(两天后找我).
首先,我在我的XML中有这个,其中包含SwipeRefreshLayout(一个片段):
<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>
Run Code Online (Sandbox Code Playgroud)
所以,为了解决这个问题,你需要在你的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>
Run Code Online (Sandbox Code Playgroud)
我希望以后可以帮助别人.
归档时间: |
|
查看次数: |
5852 次 |
最近记录: |