0

android.iでカスタムダイアログボックスを作成しました。dismiss()を使用してそれを閉じようとしましたが、それでもダイアログボックスが閉じられないので、以下のコードを参考にしてください。

void unsubPhoneNumberDialogBox(final ArrayList<String> unsubcribeList)
{
    AlertDialog.Builder builder;

    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.customalert,null);

    builder = new AlertDialog.Builder(SMSServiceListActivity.this);
    builder.setView(layout);
    alertDialog = builder.create();


    input = (EditText)layout.findViewById(R.id.txtPhoneNo);
    btnVerify = (Button)layout.findViewById(R.id.btnSendSMS);

    btnVerify.setOnClickListener(new OnClickListener() {


        @Override
        public void onClick(View v) {

            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);

            alertDialog.dismiss();

        }
    });

    alertDialog.show();
}
4

1 に答える 1

2

代わりにこのコードを試してください:

....
Dialog alertDialog = new Dialog(SMSServiceListActivity.this);
alertDialog.setContentView(R.layout.customalert);
alertDialog.show();

input = (EditText)alertDialog.findViewById(R.id.txtPhoneNo);
btnVerify = (Button)alertDialog.findViewById(R.id.btnSendSMS);

btnVerify.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        alertDialog.dismiss();
    }
});

....
于 2013-03-13T12:02:16.833 に答える