Message msg = mCommonHandler.obtainMessage(MSG_SHOW_INPUT_METHOD, dialogCreater);
mCommonHandler.sendMessageDelayed(msg, DELAY_MILLIS);
private static final int MSG_SHOW_INPUT_METHOD = 1;
private static final long DELAY_MILLIS = 300l;
private Handler mCommonHandler = new Handler() {
@Overridepublic void handleMessage(Message msg) {
switch (msg.what) {
case MSG_SHOW_INPUT_METHOD:
showInputMethod(msg.obj);
break;
default:
break;
}
}
};
protected void showInputMethod(Object obj) {
EditText editText = ((TextInputDialogCreater) obj).getmFolderName();
// 1
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(mContext.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
// 2 模拟EditText点击事件
// editText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, editText.getRight() + 5, editText.getTop() + 5, 0));
// editText.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, editText.getRight() + 5, editText.getTop() + 5, 0));