Android的:如何来传递数据给子活动?数据、Android

由网友(少年多梦不多情/*)分享简介:主要活动包括与设定值的一些变量。我创建与具有被填充有来自主活动的数据,所以我想数据必须被传递到子活动启动时的形式的子活动The main activity includes some variables with set values. I created a sub-activity with the form w...

主要活动包括与设定值的一些变量。我创建与具有被填充有来自主活动的数据,所以我想数据必须被传递到子活动启动时的形式的子活动

The main activity includes some variables with set values. I created a sub-activity with the form which has to be filled with the data from main activity so I guess the data have to be passed to the sub-activity when it starts.

有谁知道如何从主要活动传递变量值的子活动?

Does anyone know how to pass the variable values to the sub-activity from the main activity?

谢谢!

推荐答案

您可以在您的主要活动使用此方法

You can use this method in your main activity

Intent i = new Intent(this, YourMainClass.class);
i.putExtra("key", value);

结束,然后在子活动得到这种方法的价值,一般在onCreate事件

end then in the sub activity get the value with this method, usually in the onCreate event

int value = getIntent().getExtras().getInt("key");

我希望这hepls。

I hope this hepls.

阅读全文

相关推荐

最新文章