我使用 alertdialog 使用编辑文本显示我的 txt 文件内容。这是用于警报对话框的代码
File sdcard = Environment.getExternalStorageDirectory();
file = new File(sdcard.getPath() + Constants.USERNOTE_FOLDER + "/"+value);
System.out.println("txt file path name : "+file);
//Read text from file
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
}
catch (IOException e) {
//You'll need to add proper error handling here
}
System.out.println("text value : "+text);
String filename=null;
String toRemove = ".txt";
if(value.endsWith(toRemove)) {
filename=value.substring(0,value.length()-toRemove.length());
}
System.out.println("file name : "+filename);
LayoutInflater factory = LayoutInflater.from(ViewUserNote.this);
final View textEntryView = factory.inflate(R.layout.readusernote, null);
EditText readval = (EditText)textEntryView.findViewById(R.id.readtext);
readval.setText(text);
Builder alert = new Builder(ViewUserNote.this);
AlertDialog dialog =alert.create();
dialog.setTitle(filename);
dialog.setView(textEntryView);
dialog.show();
在此,当我单击编辑文本时,不应显示键盘。我应该如何实施 tis。请任何人帮助我....