我有一个文件列表,当用户保存文件时,我想刷新列表以便显示新文件。这是我尝试过的。
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();
}
}
});