从传递意图数据到其他意图 [英] pass data from intent to an other intent

查看:99
本文介绍了从传递意图数据到其他意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个意图和两个活动秒。

我在第一个意图的EditText

我想用在的EditText 文本在第二个意图,并传递给第二个意图

I want to use the text in the EditText in the second intent and pass to the second intent

Intent myIntent = new Intent(mycurentActivity.this, secondActivity.class);
startActivity(myIntent); 

感谢你在前进

推荐答案

您寻找<一href="http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20java.lang.String%29">Intent#putExtra(String,字符串)。

下面是一个例子:

Intent myIntent = new Intent(mycurentActivity.this, secondActivity.class);
myIntent.putExtra("key", myEditText.Text.toString();
startActivity(myIntent); 

当您收到的意向,你可以再次提取它:

When your receiving the Intent you can extract it again:

String text = myIntent.getStringExtra("key");

(http://developer.android.com/reference/android/content/Intent.html#getStringExtra(java.lang.String))

(http://developer.android.com/reference/android/content/Intent.html#getStringExtra(java.lang.String))

这篇关于从传递意图数据到其他意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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