如何在 ViewPager 中设置图像和文本视图,每页序列号来自 JSON in android

How to set images and textviews in ViewPager with serial per page from JSON in android

我在 android 中使用 ViewPager 进行设计布局。我已经从 json 获取数据了。我将所有图像和相关图像名称设置到 ViewPager 中,但它每页显示每个图像,当我们向后滚动时,这些图像消失了。但我的议程是 3 个图像和图像名称在 android 的 ViewPager 中设置每个页面(意味着每个页面有 3 个图像和那些名称)。任何人知道解决方案请回复我。

我上传并附上我的布局图片以供理解之用..

您可以尝试使用 setOffscreenPageLimit 以保留您的所有页面 "alive"。

Set the number of pages that should be retained to either side of the current page in the view hierarchy in an idle state. Pages beyond this limit will be recreated from the adapter when needed. (...) If you have a small number of pages (3-4) that you can keep active all at once, less time will be spent in layout for newly created view subtrees as the user pages back and forth.