0
我目前正在试图让我的代码拒绝空(空)输入,每次我输入任何值为它崩溃,但告诉它拒绝“0”工作(如在否则如果代码的一部分)。Android - 拒绝空输入问题
boolean check_input1 = Add.this.input.getText().toString().equals(null);
boolean check_input2 = Add.this.input2.getText().toString().equals(null);
boolean check_input3 = Add.this.input3.getText().toString().equals(null);
float pricecheck_input2 = Float.valueOf(Add.this.input2.getText().toString().trim()).floatValue();
float pricecheck_input3 = Float.valueOf(Add.this.input3.getText().toString().trim()).floatValue();
if (check_input1 == true | check_input2 == true | check_input3 == true) {
// prepare the alert box
AlertDialog.Builder alertbox = new AlertDialog.Builder(Add.this);
// set the message to display
alertbox.setMessage("No fields may be blank");
alertbox.show();
}
else if (pricecheck_input2 == 0 | pricecheck_input3 == 0) {
// prepare the alert box
AlertDialog.Builder alertbox = new AlertDialog.Builder(Add.this);
// set the message to display
alertbox.setMessage("Prices must be greater than 0");
alertbox.show();
}
else {
new InsertDataTask().execute(Add.this.input.getText().toString(), Float.toString(abv_ppl_calculation), Add.this.input3.getText().toString());
}
帮助将不胜感激!
请使用logcat显示崩溃的完整堆栈跟踪。 – 2011-01-26 23:29:51