use*_*410 20 android android-dialog android-dialogfragment
我试图按下按钮关闭自定义对话框
//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;
Run Code Online (Sandbox Code Playgroud)
dialog.dismiss对我不起作用.我只是尝试将此自定义对话框用作帮助屏幕,并希望按下按钮关闭它.
我是Android开发人员的新手,但已经尝试了很多个小时
谢谢你的任何建议
Ale*_*man 32
final Dialog dialog = new Dialog(BrowseActivity.this);
Run Code Online (Sandbox Code Playgroud)
你需要小写的对话框.
public void onClick(View v) {
dialog.dismiss();
}
Run Code Online (Sandbox Code Playgroud)
也AlertDialog.Builder可能是更好的选择.
| 归档时间: |
|
| 查看次数: |
33483 次 |
| 最近记录: |