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

后端 未结 7 2084
闹比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:40

    get the value of edit text by

    String text = edit_text.getText.toString;
    

    then pass it to other activity like

    intent.putExtra("text", text);
    

    In that activity get it onCreate through bundle like

    Bundle extras = getExtra().getIntent();
    String text = extras.getString("text");
    

    now set this value in your edittext like

    edit_text2.setText(text);
    

    modify this code according to you.

提交回复
热议问题