分享我的整个活动的所有意见的价值 [英] Share a value across all views of my activity

查看:102
本文介绍了分享我的整个活动的所有意见的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题更像是一个关于你们会怎么做讨论。

This question is more like a discussion about how you guys would do it.

我开发一个具有角色创造的应用程序,但在两个不同的活动,出现这种创造。

I'm developing an application that has an Avatar Creation, but this creating occurs across two different Activities.

在第一个用户选择是否是男人还是一个女人和一个名字,下一个活动的用户必须选择自己的脸,头发,衣服等。

In the first one the user selects whether is man or a woman and a name, in the next Activity the user has to select his face, hair, clothes and etc.

由于意见对头发等的变化,如果用户是男的还是你会如何实现的方式来传递的性别价值,所有的浏览女人?

Since the views for hair and etc changes if the user is a man or a woman how would you implement a way to pass the gender value to all the Views?

我想使用一个静态成员持有的价值,所以我可以我的看法内部访问,或者我应该使用共享preferences做到这一点。

I was thinking about using a static member to hold the value so I could access inside my views, or maybe I should use SharedPreferences to do it.

我想使用共享preferences是一种更优雅的方式做,但我不知道如果没有做任何其他更好,更优雅的方式。

I think using the SharedPreferences is a more elegant way to do it but I'm wondering if there isn't any other better and more elegant way of doing it.

有没有人想过其他的实现?

Has anyone thought about other implementations?

推荐答案

如果它只有像性别的小信息,我不使用静态变量(Ofcourse静态变量,如果你的应用程序将成为空看到多大的危害崩溃时它在背景中)。

If its only a small information like "gender" i don't see much harm using "Static" variable(Ofcourse the static variable will become null if your app crashes when its in the background).

共享preference会好,如果你想要的信息是的持续(但我没有看到你需要这个)。

SharedPreference will come good if you want the information to be persistent(But i don't see you need this).

还有一个选择是你可以在应用类扩展到存储所有活动的静态数据。

One more choice is you do can extend the application class to store the static data across activities.

这篇关于分享我的整个活动的所有意见的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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