//界面未加载完全而无法弹出软键盘,所以延迟,但是延迟的时间不确定
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
InputMethodManager inputManager = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
},200);
//输入框自动弹出键盘
edt.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
});
edt.requestFocus();
edt.setSelection(edt.getText().length());//设置输入框焦点置于文字后,默认总是在内容前