1. 确认对话框
String message = getString(R.string.delete_message).replace("%s", username);
new AlertDialog.Builder(AccountDisplay.this)
.setTitle(getText(R.string.delete))
.setIcon(android.R.drawable.ic_menu_delete)
.setMessage(message)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
boolean ret = false;
try {
boolean isdir = deletefile.isDirectory();
if (deletefile.isDirectory()) {
FileTools.delAllFile(deletefile.getAbsolutePath());
ret = deletefile.delete();
} else {
ret = deletefile.delete();
updateMediaDatabase(deletefile);
}
if (isdir)
FileManagerActivity.this
.sendBroadcast(new Intent("FM_DIR_DELETED"));
} catch (Exception e) {
e.printStackTrace();
}
if (ret == true) {
setPath(mPath);
} else {
Toast.makeText(FileManagerActivity.this, getText(R.string.delete_fail),
Toast.LENGTH_SHORT).show();
}
return;
}
})
.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
return;
}
})
.show();
Android砖头快
最新推荐文章于 2024-11-11 17:38:48 发布