【发布时间】:2015-08-26 15:56:35
【问题描述】:
public void validateData() {
EditText txtdate = (EditText) findViewById(R.id.txtdate);
Integer value = Integer.parseInt(txtdate.getText().toString());
if (txtdate.getText().toString().length()==0)
txtdate.setError("field cannot be empty please enter the correct values");
else if (value>31 ||value<1)
txtdate.setError("Date must be from 1 to 31");
else {
Intent intentuserinput=new Intent(getApplicationContext(),UserEpenses.class);
startActivity(intentuserinput);
}
}
我的这段代码只有在我只有/任何一个“if”和else但不能同时使用两个if时才有效。我在模拟器上得到的消息是myApp stopped working我的调试器是正常的。
【问题讨论】:
-
validateData()方法何时被调用? -
“myApp 停止工作”并不意味着您的应用程序崩溃了。日志猫说什么?
标签: android android-edittext parseint