Android закрыть настраиваемое диалоговое окно

Я пытаюсь закрыть настраиваемое диалоговое окно при нажатии кнопки

        //set up dialog
        Dialog dialog = new Dialog(BrowseActivity.this);
        dialog.setContentView(R.layout.about);
        dialog.setTitle("This is my custom dialog box");
        dialog.setCancelable(true);
        //there are a lot of settings, for dialog, check them all out!

        //set up text
        TextView text = (TextView) dialog.findViewById(R.id.TextView01);
        text.setText(R.string.app_help_message);

        //set up image view
        ImageView img = (ImageView) dialog.findViewById(R.id.ImageView01);
        img.setImageResource(R.drawable.icon);

      //set up button
        Button button = (Button) dialog.findViewById(R.id.Button01);
        button.setOnClickListener(new View.OnClickListener() {
        @Override
            public void onClick(View v) {
            Dialog.dismiss();

            }
        });

        //now that the dialog is set up, it's time to show it    
        dialog.show();

       return true;

dialog.dismiss у меня не работает. Я просто пытаюсь использовать этот настраиваемый диалог в качестве экрана справки и хочу, чтобы нажатие кнопки закрыло его.

Я новичок в разработке Android, но пробую это уже много часов

Спасибо за любой совет

20
задан UmAnusorn 10 October 2016 в 11:13
поделиться