刷卡后,当保存选项卡信息 [英] Saving tab information after swipe

查看:125
本文介绍了刷卡后,当保存选项卡信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序3个标签。
在我的第一个选项卡我需要从URL和使用用户位置读取JSON数据。它大约需要2-3秒加载页面。
我的问题开始时我实现的标签,而现在每一次IM旁边和背部刷卡,相关信息被重新读取。

I have 3 tabs in my application. In my first tab I need to read JSON data from URL and using the user location. It takes about 2-3 seconds to load the page. My problem starts when I implemented tabs, and now every time im swiping next and back, the info is re-fetched.

我尝试以下解决方案:
我搬到我的方法的 MainActivity ,然后创建一个变量名为 isUpdated ,并将其更新为 1 如果该信息已被成功取出。自那时起,标签数据被刷卡走了之后,它显示的空白空的标签。
据我所知,标签数据被刷到另一个选项卡后擦拭,但我需要保存选项卡的内容。

I tried the following solution: I moved my method to the MainActivity, and created a variable named "isUpdated" and updated it to 1 if the info has been fetched successfully. since then, the tab data is gone after swiping and it shows blank empty tab. I understand that the tab data is wiped after swiping to another tab, but I need to save the tab content.

我如何保存选项卡信息,并显示用户刷卡到下一个选项卡后,无需一遍又一遍重新获取数据?

How I can save the tab information and show it after the user swiped to the next tabs, without re-fetching the data over and over again?

推荐答案

如果您使用的是 ViewPager 然后设定关闭屏幕页面限制,不同的东西。

if you are using ViewPager then set your off screen page limit to something different

例如:

mViewPager.setOffscreenPageLimit(2);

应为3个标签足以

should be enough for 3 tabs

这篇关于刷卡后,当保存选项卡信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆