开发者

text box error in android

开发者 https://www.devze.com 2023-02-19 02:21 出处:网络
hi in m开发者_StackOverflow社区y 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.

hi in m开发者_StackOverflow社区y 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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号