diff --git a/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index 095b8a8..f32b267 100644 --- a/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/Notesmaster/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -138,14 +138,34 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD e.printStackTrace(); } } + /** + * 显示操作选择对话框 + * 1. 设置对话框标题为应用名称 + * 2. 显示笔记内容片段作为对话框消息 + * 3. 提供确定按钮 + * 4. 如果屏幕是亮屏状态,额外提供进入按钮 + * 5. 设置对话框关闭监听器 + */ private void showActionDialog() { + // 创建AlertDialog构建器 AlertDialog.Builder dialog = new AlertDialog.Builder(this); + + // 设置对话框标题(使用应用名称资源ID) dialog.setTitle(R.string.app_name); + + // 设置对话框消息内容(显示笔记片段) dialog.setMessage(mSnippet); + + // 添加确定按钮(使用资源ID设置按钮文字,并设置当前Activity为点击监听器) dialog.setPositiveButton(R.string.notealert_ok, this); + + // 检查屏幕是否亮屏 if (isScreenOn()) { + // 如果是亮屏状态,添加进入按钮 dialog.setNegativeButton(R.string.notealert_enter, this); } + + // 显示对话框并设置关闭监听器(当前Activity实现OnDismissListener接口) dialog.show().setOnDismissListener(this); }