我有一个使用ViewPager的三个选项卡界面设置。在第三个标签中,我有一个CardView,它可以展开/收回onclick以显示更多信息。 CardView内部是一个RecyclerView,充满了大量的数据。Android Preload Recycleview Contents
第一次打开应用程序并扩展卡片视图时,扩展动画非常滞后,但之后可以顺利扩展/缩回。 RecyclerView数据也可以在没有问题的情况下更新。
有没有办法在打开应用程序时以某种方式加载/缓存数据,因此lagg不会发生。
对不起,如果问题不好,刚开始android开发。 由于
布局第三选项卡:
<android.support.v7.widget.CardView
android:id="@+id/SF_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp">
<LinearLayout
android:id="@+id/SF_wrapper"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/SF_list"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v7.widget.CardView>
其用于膨胀recyclerView的数据是用2个浮动变量每个对象的列表。粗略长度〜50。
用于膨胀各个项目的XML:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4sp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="36sp"
android:layout_weight="1">
<TextView
android:id="@+id/value_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="lorem"
android:textSize="8sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="36sp"
android:layout_weight="1">
<TextView
android:id="@+id/value_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ipsom"
android:textSize="8sp" />
</RelativeLayout>
</LinearLayout>
展开代码/缩回cardView简单动画改变SF_frame的高度以显示RecyclerView的多个元件,它是该第一揭示其为laggy 。
什么样的数据以及他们如何被retreived?如果有图像(我认为它们可能需要大量处理器时间给初学者)尝试使用一些带有异步加载的库(首先尝试http://square.github。io/picasso /) – VizGhar
嗨,感谢您的回复,信息只是一堆数字,这是在另一个功能计算。我认为lagg并没有提取数据,只是第一次显示一堆隐藏的视图 –
您可以先添加Cardview xml吗?那么我们应该知道问题出在哪里......我不认为预加载数据是聪明的做法。只有有真正巨大的数据。 – VizGhar