【发布时间】:2014-07-22 03:04:25
【问题描述】:
我基本上是在尝试创建一个对话框,将用户输入文本作为“注释”并保存注释并在下次打开对话框时显示注释,然后用户可以添加到注释或从笔记中取出并再次保存。非常感谢您提前。
这是我目前所拥有的:
AlertDialog.Builder alert = new AlertDialog.Builder(ViewTask.this);
alert.setTitle("Task Note");
alert.setMessage("Please enter your note");
// Set an EditText view to get user input
final EditText input = new EditText(ViewTask.this);
alert.setView(input);
alert.setPositiveButton("Save", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
//String usernote = value;
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
alert.setCancelable(false);
alert.show();
break;
【问题讨论】:
-
你能描述什么不起作用吗?
-
嗨@Takendarkk,一切正常,但我不知道如何保存用户输入并在重新打开对话框时调用它。我希望可能是一个参考或方法名称,我可以查看一些见解。非常感谢您的回复。
-
需要长期保存吗?就像用户可以退出您的应用,然后在 2 天后返回并仍然看到它?
-
嘿@Takendarkk,是的,我希望能长期保存它。我想我需要一个我相信的数据库?我不知道。感谢您的回复。
-
查看此链接 --> Android Storage Options