1、第一看是否是你代码关闭了后缀名
builder.setEditTextContent(FileUtils.getLastFileName(file, true));
false(为假)是你关闭了后缀名,打开只需改为true(为真)
2、 private void renameItem(final BaseListItem item) {
final File file = new File(item.getPath());
RenameDialogBuilder builder = new RenameDialogBuilder(getContext(), file);
builder.setTitle(R.string.rename_dialog_title);
builder.setNegativeButton(R.string.discard, null);
builder.setPositiveButton(R.string.rename_dialog_save,
new RenameDialogBuilder.OnPositiveListener() {
@Override
public void onClick(DialogInterface dialog, int which, String newName) {
if (!FileUtils.exists(file)) {
Toast.makeText(getContext(), R.string.file_deleted, Toast.LENGTH_SHORT)
.show();
return;
}
// rename file.
String newName_noext = newName;
int dot = newName.lastIndexOf('.');
if ((dot >-1) && (dot < (newName.length()))) {
newName_noext = newName.substring(0, dot);
}
File newFile = FileUtils.renameFile(file, newName);
// update database.
DatabaseUtils.rename(getContext(), file, newFile);
item.setPath(newFile.getAbsolutePath());
// update list item.
item.setTitle(newName);
if (mAdapter != null) {
mAdapter.notifyItemChanged(item);
}
if (getPlayer() != null && getPlayer().isItemUsing(item)) {
getPlayer().onItemChanged((MediaItem) item);
}
}
});
builder.setEditTextContent(FileUtils.getLastFileName(file, true));
builder.show();
}