您好我正在尝试编写一个小应用程序,当系统上的这一天是星期天时,它应该会拉出一个对话框,它做得很好。但是,当我将信息放入对话框中的框中并单击提交时,它仍然显示我设置的 emptyBox 的第二个对话框。
因此,回顾一下对话框的所有项目都在工作,除了系统仍然看到 EditText 框为空但那里有一个值。该值将永远是数字。
final Dialog sundayDialog = new Dialog(this);
sundayDialog.setContentView(R.layout.sunday_dialog);
Button sundaySubmitBtn = (Button) sundayDialog
.findViewById(R.id.sundayDialogSubmitBtn);
Button sundayCancelBtn = (Button) sundayDialog
.findViewById(R.id.sundayDialogCancelBtn);
sundaySubmitBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Submit Button
setContentView(R.layout.sunday_dialog);
final EditText etAmountBought = (EditText) findViewById(R.id.amountBoughtET);
final EditText etCost = (EditText) findViewById(R.id.pricePaidET);
String amountBought = etAmountBought.getText().toString();
String cost = etCost.getText().toString();
if (amountBought.isEmpty() || cost.isEmpty()) {
//sundayDialog.dismiss();
emptyETDialogCall();
} else {
try {
mAmountBought = Integer.parseInt(amountBought);
mPricePaid = Integer.parseInt(cost);
} catch (NullPointerException e) {
Log.e(TAG, "Error in sunday dialog in try/catch");
}
}
if (mPricePaid >= 250) {
costTooHighDialogCall();
mPricePaid = 0;
}
// textBlockDisplay(); // Update the text block with input.
}
});
sundayCancelBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Cancel Button
sundayDialog.dismiss();
sundayCancelDialog();
}
});
sundayDialog.show();
}
这是在 logcat 中显示的唯一这个:
08-04 11:42:44.780: W/IInputConnectionWrapper(1209): finishComposingText on inactive InputConnection