Android Studio怎么才能让用户重新输入正确数据? 50
如图,用户的正确用法是把三个editText都填上数字才能点summary(用intent开出新的activity),但是现在如果用户留了一个及以上的editText空白...
如图,用户的正确用法是把三个 editText 都填上数字才能点summary(用intent开出新的activity),但是现在如果用户留了一个及以上的editText 空白再点summary的话,app会直接奔溃。所以我想问一下,怎么在这种情况下 弹出提醒用户填满editText 的框框 并且可以让用户重新输入?n我把我的尝试方法发出来了(当然不管用,一样奔溃)public void onClickSummaryButton(View view){ // while(check) { numberOfPeople = (TextView) findViewById(R.id.people); amount = (TextView) findViewById(R.id.amount); tip = (TextView) findViewById(R.id.tip); Toast.makeText(this, "saved", Toast.LENGTH_SHORT).show(); alert(check(numberOfPeople, amount, tip)); if (check(numberOfPeople, amount, tip)) { Toast.makeText(this,"saved", Toast.LENGTH_SHORT).show(); check = false; } } if(check(numberOfPeople, amount, tip)) { Intent intent = new Intent(Main.this, summayWindow.class); Bundle extra = new Bundle(); extra.putString("people", numberOfPeople.getText().toString()); extra.putString("amount", amount.getText().toString()); extra.putString("tip", tip.getText().toString()); sighM = sign; extra.putString("sign", sighM); intent.putExtras(extra); startActivity(intent); } } private boolean check(TextView NOP,TextView amount, TextView tip){ if( TextUtils.isEmpty(NOP.getText().toString()) || TextUtils.isEmpty(amount.getText().toString()) || TextUtils.isEmpty(tip.getText().toString())){ Log.i("!!!!!!!!!!!","CHECK"); return false; } return true; }谢谢!
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询