如何建立1按鈕,顯示雙按鈕訊息方塊 (AlertDialog): 確定,取消 注意:整個事件程式碼都必須放在 onCreate() { } 下面 .......................... 範例: import android.view.*; import android.app.AlertDialog; import android.content.DialogInterface; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("在這裡設定標題名稱"); builder.setMessage("在這裡設定要顯示的文字"); builder.setPositiveButton("確定", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { // 在這裡輸入你要輸入的程式碼 } }); builder.setNegativeButton("取消", null); builder.show();