我使用alertdialog使用編輯文本顯示我的txt文件內容。這裏是用於警報對話框的代碼如何隱藏鍵盤在android中點擊提醒對話框中的編輯文本
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();
在這個當我點擊編輯文本鍵盤不應該顯示。我應該如何實現這個。請任何一個幫我....
我已經使用這個那朵,但我不能隱藏鍵盤 – neelsnallu
看到我的編輯答案。 – meh
謝謝。我通過將焦點設置爲false來獲得結果。 – neelsnallu