1

こんにちは、小さなアプリを作成しようとしています。システムで日が日曜日の場合、正常に動作しているダイアログ ボックスを表示することになっています。ただし、ダイアログのボックスに情報を入力して送信をクリックすると、設定した emptyBox の 2 番目のダイアログが引き続き表示されます。

したがって、ダイアログ ボックスのすべての項目が機能していることを要約すると、システムはまだ 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
4

2 に答える 2

0

私はあなたの問題を手に入れたと思います。

sundayDialog.setContentView(R.layout.sunday_dialog); これは、カスタム ダイアログに設定しているビューです。これでいいです。

そして、日曜日にもう一度ボタンをクリックすると、レイアウトがリセットされ、すべてのビューが再び作成され、すべてがリセットされます。

最終的なダイアログ sundayDialog = 新しいダイアログ(これ);

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

// ここで setContent ビューを削除しました....

        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();

}

于 2013-08-06T05:31:53.163 に答える