android 代码片段

editview获取焦点并弹出键盘:

private void showKeyboard(final EditText editText){

        editText.requestFocus();

        Timer timer = new Timer();

        timer.schedule(new TimerTask() {

            @Override

            public void run() {

                InputMethodManager m = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

                m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);

            }

        }, 300);

    }

 

你可能感兴趣的:(android)