您好所有简单的问题,你如何禁用提交按钮,直到到的EditText填充是它的一个,如果命令或东西??
B =(按钮)findViewById(R.id.login);
等=(EditText上)findViewById(R.id.username);
通过=(EditText上)findViewById(R.id.password);
如果(ET&安培;通过==''){
}
b.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
对话框= ProgressDialog.show(Login.this,,
验证用户...,真正的);
新主题(新的Runnable(){
公共无效的run(){
登录();
}
})。开始();
}
});
解决方案
您可能需要做的是使用的 TextWatcher 和 onTextChanged()
检查,看看是否每一个为空。但是,你要检查的不是查看
所以不是检查文本等
和通过
,你可能想要得到的字符串
中的每个
字符串etString = et.getText()的toString()。
。字符串passString = pass.getText()的toString();
如果他们不emty和空
,再加上你想要的任何其他检查,如长度,然后
b.setEnabled(真正的);
Hello all simple question how do you disable the submit button till to edittext are filled is it an if command or something ??
b = (Button)findViewById(R.id.login);
et = (EditText)findViewById(R.id.username);
pass= (EditText)findViewById(R.id.password);
if (et & pass == ' ') {
}
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog = ProgressDialog.show(Login.this, "",
"Validating user...", true);
new Thread(new Runnable() {
public void run() {
login();
}
}).start();
}
});
解决方案
What you might want to do is use a TextWatcher and in onTextChanged()
check to see if each is empty. But you want to check the text not the View
so instead of checking et
and pass
, you probably want to get the String
in each.
String etString = et.getText().toString();
String passString = pass.getText().toString();
If they are not emty and null
, plus any other checks you want such as length then
b.setEnabled(true);