The method getText() is undefined for the type String error

后端 未结 3 1484
野趣味
野趣味 2021-01-29 12:48
 String email = email.getText().toString();

Please help getting error The method getText() is undefined for the type String

相关标签:
3条回答
  • 2021-01-29 13:09

    It seems that you have shadowed an attribute email by calling a variable with the same name.

    Hence email does not reference what you meant anymore (a textfield I suppose) but a String.

    You should change the name of your variable.

    0 讨论(0)
  • 2021-01-29 13:10

    Change - String email = email.getText().toString() to

    String emailStr = email.getText().toString()
    
    0 讨论(0)
  • 2021-01-29 13:10

    Assume the id of your EditText is email. To get the Text of the EditText you can use

    String email = ((EditText)findViewById(R.id.email)).getText().toString();
    
    0 讨论(0)
提交回复
热议问题