在Android的活动之间传递值 [英] Passing values between activities in Android

查看:125
本文介绍了在Android的活动之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于Android中的活动之间传递数据的问题。我试图让一个对象Parcelable,它的工作原理,但它的复杂实现每类。我想尝试的值存储作为一个全球性,并在其他活动获取它。我知道,我们应该避免全局变量,但目前我没有任何其他解决方案。任何建议?也许,如果我用了一个集合,它应该是Parcelable吧?

I have a question about passing data between activities in Android. I tried to make an object Parcelable, it works but it's complicated to implement for every class. I want to try to store the value as a global and fetch it in the other activity. I know that we should avoid globals, but at the moment I don't have any other solution. Any advice? Maybe if I used a collection, it should be Parcelable, right??

在此先感谢:)

推荐答案

我有误解,我们的整体构想一种强烈的感觉活动。纵观意图的传递数据,我可以说活动额外的机制的发明一样东西全足够W / O需求交换的大量相互之间的数据。但我还是没有带了Android的核心设计师的一个点。检查<一href=\"http://stackoverflow.com/questions/1694301/good-alternatives-to-share-a-complex-tree-of-objects-between-activities-in-androi\">this螺纹,MB你会发现它有帮助。

I have a strong feeling that we misunderstand the whole conception of Activities. Looking at the intent's extra mechanism of passing data I can say Activity was invented like something all-sufficient w/o need of exchanging large amount of data between each other. But I still havn't got a point of android core designers. Check this thread, mb you'll find it helpfull.

这篇关于在Android的活动之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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