我有一個自定義佈局的對話,我嘗試關閉它,當我按下一個按鈕:辭退自定義對話框問題
private void showAboutDialog() {
dialog = new Dialog(MainMenu.this);
dialog.setContentView(R.layout.about_dialog);
dialog.setCancelable(true);
dialog.setTitle(R.string.about_title);
dialog.show();
LayoutInflater inflater = (LayoutInflater)
getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.about_dialog,
(ViewGroup) findViewById(R.id.layout_root));
Button closeButton = (Button) layout.findViewById(R.id.about_close_button);
closeButton.setOnClickListener(new Button.OnClickListener() {
public void onClick(View view) {
dialog.dismiss();
}
});
}
但它不工作。
您是否在LogCat上看到任何錯誤? – 2010-08-16 14:39:55