在android中保存实例状态 [英] Saving instance state in android

查看:100
本文介绍了在android中保存实例状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为'create'的活动屏幕,用户在角落按下FAB,并出现一个微调器(您可以添加任意数量的微调器)。用户然后从微调器中选择值。



我还有另一个名为view的活动屏幕,除了一些位之外,它们具有完全相同的代码。



当用户创建微调器并从中选择值时,是否可以这样做,这些微调器和值会自动出现在视图屏幕上?



我尝试了什么:



我试过阅读有关保存实例状态但我不知道如何它适用于微调器并将它们保存在两个屏幕上

解决方案

使用其中一个Intent.putXXX方法在create和view之间传递值,如意图  |  Android开发者 [ ^ ]。

I have an activity screen called 'create' where the user presses the FAB in the corner, and a spinner appears (you can add as many spinners). THe user then selects values from the spinners.

I also have another actvity screen called 'view' which will have exactly the same code except some bits.

Is it possible to make it so when the user creates spinners and selects values from them, these spinners and values appear on the view screen automatically?

What I have tried:

I have tried reading about saving instance states but I don't know how it works with spinners and saving them on two screens

解决方案

Use one of the Intent.putXXX methods to pass the values between create and view, as described in Intent  |  Android Developers[^].


这篇关于在android中保存实例状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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