活动机器人之间传送int变量 [英] Transferring int variable between activities Android
本文介绍了活动机器人之间传送int变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想提出一个问答游戏。不过,我需要补充的是可以修改分数的变量。本场比赛的工作方式是,它使用几个不同的活动。我怎么能发送这个分数和整个活动的进行修改。
I am making a quiz game. However, I need to add a score variable that can be modified. The way the game works is it uses a few different activities. How can I transmit this score and modify it throughout the activities.
推荐答案
下面是传递一个整数从一个活动到另一个活动的一个例子。
Here's an example of passing an integer from one activity to another activity.
开始ActivityA并传递给它的INT是这样的:
Start ActivityA and pass it the int like this:
Intent theIntent = new Intent(this, ActivityA.class);
theIntent.putExtra("somename", intVariable);
startActivity(theIntent);
获取整数从内部ActivityA是这样的:
Get the integer from within ActivityA like this:
int i = getIntent().getIntExtra("somename");
这篇关于活动机器人之间传送int变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文