不了解哪种数据类型是name.gettext()。tostring()

首先,如果它太基础了,我很抱歉,但是我已经使用了很长时间,但是没有找到答案。 Iam构建的应用程序仅在输入特定的电子邮件和密码时会显示“欢迎”,否则显示“电子邮件/密码不正确”,但我不明白代码的问题所在。我认为问题出在string.gettext()。tostring()。我不知道如何在if循环中使用它...

```
 package com.example.project2;

 import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.EditText;
  import android.widget.Toast;

public class Project2 extends AppCompatActivity {

public void login(View view) {
EditText email= (EditText) findViewById(R.id.emailEditText);
EditText password= (EditText) findViewById(R.id.passwordEditText);
Log.i("info","Button pressed!");

String Email= email.getText().toString();
String Password = password.getText().toString();

Boolean email1 = Email.contains("example876@gmail.com");
Boolean password1 = Password.contains("asad123");

if (email1){
  Toast.makeText(this, "Welcome", Toast.LENGTH_LONG).show();
} else if (password1) {
  Toast.makeText(this, "The method worked", Toast.LENGTH_LONG).show();
} else {
  Toast.makeText(this, "Incorrect Username/Password", Toast.LENGTH_LONG).show();

}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_project2);
  }
} 
```

有人请帮助! 提前致谢...

评论