我有一个文件列表,当用户保存文件时,我想刷新列表,以便新文件显示出来。这是我试过的。为什么我的列表不清爽?
private IconifiedTextListAdapter itla = new IconifiedTextListAdapter(this);
...
private void saveAs(){
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Save as");
alert.setMessage("(Will be saved in the current working directory)");
// Set an EditText view to get user input
final EditText input = new EditText(this);
alert.setView(input);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
String tmpText = et.getText().toString();
try {
File tempfile = new File(currentDirectory, value);
FileWriter writer = new FileWriter(tempfile);
writer.write(tmpText);
writer.flush();
writer.close();
changed=false;
itla.notifyDataSetChanged();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
你似乎从来没有进一步使用该适配器(如获取/添加到它)。我认为没有什么需要更新。 – 2013-03-03 18:36:17
谢谢:)我调用fill()来填充onCreate()中的列表,但忘了在saveAs()中再次调用它我觉得很蠢。 – RapsFan1981 2013-03-03 18:40:55
请添加答案并将其标记为已解决,它可以帮助他人。 – 2013-06-25 13:15:09