Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

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

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..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...