我被我的应用程序的最后一件事困住了。当按钮bSubmit被按下时,除了在EditText框中没有给出输入时强制关闭应用程序而不是强制关闭时,所有的功能都可以工作,我试图放置一个祝酒信息,这也不起作用。我想有一个在我的逻辑缺陷onButtonClick导致部队关闭的缺陷“或逻辑”
if (v.getId() == R.id.bSubmit) {
String numstr = numberEditText.getText().toString();
String pontstr = pointEditText.getText().toString();
int point = Integer.parseInt(pontstr);
//takes in the customer's number and the purchase amount
//search for the customer's number in database
DatabaseHelper helper = new DatabaseHelper(this);
Log.d("onButtonClick",""+numstr);
customer = helper.searchCustomer(numstr);
if (numstr.equals(null) || pontstr.equals(null)){
Context toastcontext = getApplicationContext();
CharSequence text ="You haven't put any value";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(toastcontext,text, duration);
toast.show();
}
if (customer.getuNum() != null && customer.getuNum().equals(numstr)) {
//if found then add the amount as new points
//int row = helper.searchRow(customer.getuNum());
// int point = helper.searchPoint(customer.getuNum());
int pnt = customer.getPoint() + point;
Log.d("MainActivity",customer.getuNum()+" pnt "+pnt);
helper.updatePoint(pnt,customer.getuNum());
currentPoint.setText("Your point is "+pnt);
}
else {
//create a new customer and add the info to database
Customer customer = new Customer();
customer.setuNum(numstr);
customer.setPoint(point);
helper.insertCustomer(customer);
Log.d("MainActivity","customer null num "+customer.getuNum()+" point "+point);
currentPoint.setText("Your point is " + point);
}
numberEditText.getText().clear();
pointEditText.getText().clear();
}
你能提供的致命日志 –
https://docs.google.com/document/d/1AW2ZDiZmvKgFqYroQWoAKUziwYd- UL4VM0S-iVR4g5g /编辑?usp =分享 –