禁止登录按钮,直到申请表已填写的Andr​​oid SDK [英] Disable login button till form is filled android sdk

查看:96
本文介绍了禁止登录按钮,直到申请表已填写的Andr​​oid SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好所有简单的问题,你如何禁用提交按钮,直到到的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);

这篇关于禁止登录按钮,直到申请表已填写的Andr​​oid SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆