判断已勾选的CheckBox后面跟着的editText内容不为空(一个或者多个editText)

来源:互联网 发布:linux如何安装vsftpd 编辑:程序博客网 时间:2024/05/28 06:05

    以下方法为判断已勾选的CheckBox后面跟着的editText内容不为空(一个或者多个editText)

/**
  * check whether the EditText is no empty and not equal "0" when the CheckBox is checked.
  * @param mCheckBox
  * @param mEditText
  * @return
  */
 public boolean checkInput(CheckBox mCheckBox, EditText... mEditText) {
  boolean flag = true;
  if (isCheckBoxChecked(mCheckBox)) {
   for (int i = 0; i < mEditText.length; i++) {
    String text = mEditText[i].getText().toString();
    if (TextUtils.isEmpty(text) || text.equals("0")) {
     flag = false;
     Toast.makeText(getActivity(), R.string.input_invalid, Toast.LENGTH_SHORT).show();
     break;
    }
   }
  }
  return flag;
 }

 

/**
  * check whether the CheckBox is checked.
  * @param mCheckBox
  * @return
  */
 public boolean isCheckBoxChecked(CheckBox mCheckBox) {
  if(mCheckBox != null){
   return mCheckBox.isChecked();
  }
  return false;
 }

0 0
原创粉丝点击