Change widget text in another activity

Posted by Darmen on Stack Overflow See other posts from Stack Overflow or by Darmen
Published on 2010-04-08T15:34:56Z Indexed on 2010/04/08 16:13 UTC
Read the original article Hit count: 270

Filed under:
|
|

Suppose I have ActivityA and ActivityB, also suppose that ActivityA is active. I need to:

  1. Programmatically set a text of EditText in ActivityB from ActivityA
  2. Launch ActivityB

Here's my code:

EditText res;
final LayoutInflater factory = getLayoutInflater();
final View resultView = factory.inflate(R.layout.ActivityB, null);

// get widget
res = (EditText) resultView.findViewById(R.id.txtResult);

// set the text
res.setText("foobar");


// create intent
Intent i = new Intent(ActivityA.this, ActivityB.class);
startActivity(i);

ActivityB starts, but without any text in txtResult. How can I fix that?

© Stack Overflow or respective owner

Related posts about android

Related posts about activity