0

我的问题:我想让一个活动包含微调器和编辑框和按钮我想让按钮禁用,直到用户填写框并从微调器中选择一个项目。我写了它检查是否为空它禁用按钮但是当我填充框时按钮仍然禁用..!!第二个问题:当我将提示放入编辑框时它会在检查框是否为空时读取它!如果选择了微调器,我该如何检查?*value 是editText 的名称 *enterBtn 是按钮的名称。

    if(x.matches("")){
                enterBtn.setEnabled(false);
                 onStart();
            }else {
                enterBtn.setEnabled(true);
            }
            enterBtn.setOnClickListener(new OnClickListener(){

                public void onClick(View arg0) {
                    // TODO Auto-generated method stub


                if(Integer.valueOf(x)>(70)){
                Value.setText("plz dont enter more than 500");
                    }else{
........
...}
4

1 回答 1

1
Use Listener For Edit Box And Spinner..when you enters text to the Edit Text it Does not Check Whether It Has Text Entered Or not..thats why your button gets disabled..hear is the listner where you can actually get when someone entered text to Editext.

tv = (TextView)findViewById(R.id.charCounts);

    textMessage = (EditText)findViewById(R.id.textMessage);

    textMessage.addTextChangedListener(new TextWatcher(){
        public void afterTextChanged(Editable s) {
            i++;
            tv.setText(String.valueOf(i) + " / " + String.valueOf(charCounts));
        }

    }); 
于 2013-02-13T08:17:50.110 回答