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

后端 未结 7 2120
闹比i
闹比i 2020-12-16 07:01

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

7条回答
  •  醉话见心
    2020-12-16 07:26

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

提交回复
热议问题