Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass edittext value to another activity's edittext?

Tags:

android

My project's requirement is : edittext value is first entered by user and that same value will be visible in another activity's editext , which should be read only..

like image 769
pooja Avatar asked May 29 '13 10:05

pooja


1 Answers

You can pass it using Intent's putExtra() method. try this way,

In First Activity,

Intent intent = new Intent ( FirstAcvity.this, SecondActivity.class ); 
intent.putExtra ( "TextBox", editText.getText().toString() );
startActivity(intent); 

Now, in second activity, use following code,

Intent i = getIntent(); 
String text = i.getStringExtra ( "TextBox","" ); 
// Now set this value to EditText 
secondEditText.setText ( text ); 
secondEditText.setEnable(false);
like image 183
Lucifer Avatar answered Nov 15 '22 17:11

Lucifer