最近在做一款横屏App的时候,遇到,当点击横屏Fragment中的item的时候,跳转到数据activity界面时候,然后点击返回,发现界面数据空白,感觉数据也还在,该走的方法也走了,但是界面就是空白的,这是什么鬼?然后不停的打断点发现该走的流程就是走了,但是界面就是不显示
这个问题出在哪里呢,然后我就开始打印Fragment的生命周期,看看他在这个过程中走了哪些个方法.最后再onResume()方法中,加载如果adapter不为空,就前置刷新这个界面, 如果为空,就网络请求,这样代码写完了之后,发现还是返回后,界面还是无法显示,后来在网上找了很多方法,还是不管用,当时这样想,这条路走不通,是不是xml出了问题,返回的时候,不会走OnCreate 方法,是不是RecyclerView的高度影响了界面的显示,
不能显示前的xml 代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/hotList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</android.support.constraint.ConstraintLayout>