我在我的main.class
文件中有一個簡單的代碼文本,它創建一個popup
對話框。當我嘗試使用finish();
方法關閉popupdialog時,它會關閉整個應用程序,而不僅僅是彈出對話框。我該如何解決這個問題? (這是爲Android,看看我的評論以及)。如何關閉彈出對話框?
這是代碼:
Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.start_dialog);
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.loss);
//set up image view
ImageView img = (ImageView) dialog.findViewById(R.id.ImageView01);
img.setImageResource(R.drawable.golf_ball);
//set up button
Button button = (Button) dialog.findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//now that the dialog is set up, it's time to show it
dialog.show();
什麼編程語言/ OS /環境/等? – 2011-03-25 12:26:48
作業問題... – 2011-03-25 12:47:13
android mobile(JAVA)。 – jesmar 2011-03-25 13:02:16