以下方法为判断已勾选的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;
}