text box error in android

 ̄綄美尐妖づ 提交于 2020-01-06 16:01:25

问题


hi in my app i have 2 Activity named as A and B.

Now i am placing 2 edit boxes for typing the first name and last name, with an OK button in Activity A.

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.

pls help me...


回答1:


You can use putExtra and getStringExtra with your Intent to pass String parameters to a new Activity.

In Activity A:

Intent intent = new Intent(this, B.class);
intent.putExtra("firstName", firstName);
intent.putExtra("lastName", lastName);
startActivity(intent);

In Activity B:

@Override
protected void onCreate(Bundle savedInstanceState) {
    String firstName = getIntent().getStringExtra("firstName");
    String lastName = getIntent().getStringExtra("lastName");
        ....
}

There are also getFooExtra and putExtra methods for all of the other basic datatypes.



来源:https://stackoverflow.com/questions/5410551/text-box-error-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!