我有一個文件列表,當用戶保存文件時,我想刷新列表,以便新文件顯示出來。這是我試過的。爲什麼我的列表不清爽?
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