Get text string from EditText?

后端 未结 3 1141
北恋
北恋 2020-12-29 18:08

It seems I can\'t figure out how to get the text string out of EditText. I want to use the text from the EditText at pressing the button.

l

相关标签:
3条回答
  • 2020-12-29 18:41
    EditText txtDescription =
            (EditText) layout.findViewById(R.id.txtDescription);
    
    
    String message = txtDescription.getText().toString(); 
    
    0 讨论(0)
  • 2020-12-29 18:42

    Try this :

    EditText edt = (EditText)findViewById(R.id.edittext);
    String xyz = edt.getText().toString();
    
    0 讨论(0)
  • 2020-12-29 18:55

    Solved the problem myself:

    final EditText edittextDescription = (EditText) findViewById(R.id.edittext);
    

    must be

    final EditText edittextDescription =  (EditText)layout.findViewById(R.id.txtDescription);
    

    And then I can do this to get the string

    String s = edittext.getText().toString();
    
    0 讨论(0)
提交回复
热议问题