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

后端 未结 7 2117
闹比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:41

    Based on Lucifer's answer you could use a TextView in the second activity:

    First Activity:

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

    Second Activity:

    Intent i = getIntent();
    tv.setText(i.getStringExtra("text"); //tv is the TextView
    

提交回复
热议问题