我想在字段为空时显示吐司。
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
aut.signInWithEmailAndPassword(edittext1.getText().toString(), edittext2.getText().toString()).addOnCompleteListener(MainActivity.this, _aut_sign_in_listener);
}
});
答案 0 :(得分:2)
在此之前
aut.signInWithEmailAndPassword(edittext1.getText().toString(), edittext2.getText().toString()).addOnCompleteListener(MainActivity.this, _aut_sign_in_listener)
尝试如下检查数据是否为空
if (edittext1.getText().toString().isEmpty() || edittext2.getText().toString().isEmpty()) {
Toast.makeText(this,"fill the required field",Toast.LENGTH_LONG).show();
} else {
aut.signInWithEmailAndPassword(edittext1.getText().toString(), edittext2.getText().toString()).addOnCompleteListener(MainActivity.this, _aut_sign_in_listener)
}
答案 1 :(得分:2)
尝试一下:
当这些字段为空时,请应用此检查:-
if (edittext1.getText().toString().isEmpty()) {
Toast.makeText(getApplicationContext(),"Edit text 1 can not be empty",Toast.LENGTH_LONG).show();
}
else if (edittext2.getText().toString().isEmpty()) {
Toast.makeText(getApplicationContext(),"Edit text 2 can not be empty",Toast.LENGTH_LONG).show();
}
else{
//success code here
aut.signInWithEmailAndPassword(edittext1.getText().toString(), edittext2.getText().toString()).addOnCompleteListener(MainActivity.this, _aut_sign_in_listener);
}
答案 2 :(得分:1)
“ setError” 代替文本,来编辑文本。会更好
editText.setError("This field can not be blank");
答案 3 :(得分:1)
尝试一下
"DatabaseProvider": "MSSQL", //could be MySQL, SQLite etc etc
"ConnectionStrings": {
"MSSQL": "Server=(localdb)\\MSSQLLocalDB;Database=XXX_db;Trusted_Connection=True;MultipleActiveResultSets=true",
"SQLite": "Data Source=XXX_db.db"
}