Опитвам се да затварям персонализирания диалог за натискане на бутон
//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;
dialogue.dismiss не работи за мен. Просто се опитвам да използвам този персонализиран диалогов прозорец като помощен екран и искам бутон да го натиснете, за да го затворите.
Аз съм много нов за Android, но се опитвам това много часове
Благодаря за всички съвети
Отговори:
31 за отговор № 1final Dialog dialog = new Dialog(BrowseActivity.this);
Нуждаете се от малък диалог.
public void onClick(View v) {
dialog.dismiss();
}
Също AlertDialog.Builder
може да бъде по-добър избор за вас.
2 за отговор № 2
Можете да извикате отхвърляне (); в диалоговия прозорец. Това работи за мен.