在Android的文本框中输入错误 [英] text box error in android
问题描述
在我的应用程序您好,我有2个活动命名为A和B的。
hi in my app i have 2 Activity named as A and B.
现在我把2编辑框为活动打字的姓氏和名字,以确定按钮。
Now i am placing 2 edit boxes for typing the first name and last name, with an OK button in Activity A.
输入数据和pressing确定按钮后,我要显示的姓氏和名字作为活动B的标题文本。
After entering the data and pressing OK button i want to show the first name and last name as the title text of Activity B.
我已经尝试并取得成功在通过这些名字是受我在同一个应用程序的邮件。
i have tried and succeed in passing those names to be subject of my mail in the same app.
请帮我...
推荐答案
您可以使用<一个href=\"http://developer.android.com/reference/android/content/Intent.html#putExtra%28java.lang.String,%20java.lang.String%29\"相对=nofollow> putExtra 和<一个href=\"http://developer.android.com/reference/android/content/Intent.html#getStringExtra%28java.lang.String%29\"相对=nofollow> getStringExtra 与你的意图传递字符串参数到一个新的活动。
You can use putExtra and getStringExtra with your Intent to pass String parameters to a new Activity.
在活动答:
Intent intent = new Intent(this, B.class);
intent.putExtra("firstName", firstName);
intent.putExtra("lastName", lastName);
startActivity(intent);
在活动B:
@Override
protected void onCreate(Bundle savedInstanceState) {
String firstName = getIntent().getStringExtra("firstName");
String lastName = getIntent().getStringExtra("lastName");
....
}
也有 getFooExtra
和 putExtra
所有其他基本数据类型的方法。
There are also getFooExtra
and putExtra
methods for all of the other basic datatypes.
这篇关于在Android的文本框中输入错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!