在我的應用程序中,我有EditText對話框。我想要獲得編輯框automaticaly.i.e的keyboad,當顯示對話框時應該顯示鍵盤。有沒有辦法顯示鍵盤而不觸及EditText。在對話框中的Android EditText
我加入對話代碼
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(APP_NAME);
builder.setMessage(message);
// Use an EditText view to get user input.
final EditText inputDevice = new EditText(this);
final EditText inputTester = new EditText(this);
if (id == DLG_ID_TESTER) {
inputTester.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
// inputTester.setThreshold(1);
inputTester.setSelectAllOnFocus(true);
inputTester.requestFocus();
inputTester.setId(TXT_ID);
builder.setView(inputTester);
} else {
inputDevice.setId(TXT_ID);
inputDevice.setSelectAllOnFocus(true);
builder.setView(inputDevice);
}
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
if (id == DLG_ID_TESTER) {
String val = inputTester.getText().toString();
testerName = val;
txtTesterName.setText(testerName);
} else if (id == DLG_ID_DEVICE) {
String value = inputDevice.getText().toString();
deviceId = value;
txtDeviceId.setText(deviceId);
}
return;
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
});
return builder.create();
}
感謝您的鏈接 – user1767260