Android Show Soft Keyboard When First Activity Starts?

前端 未结 3 1891
遥遥无期
遥遥无期 2020-12-29 16:47

I need to display the virtual keyboard when the application starts, but so far I\'ve failed.

I use this code in method \"OnCreate\"to display the virtual keyboard

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 16:57

    I Found the solution:

    txtPassword.postDelayed(new Runnable() {
                @Override
                public void run() {
                    InputMethodManager keyboard = (InputMethodManager)
                    getSystemService(Context.INPUT_METHOD_SERVICE);
                    keyboard.showSoftInput(txtPassword, 0); 
                }
            },200);
    

    Thanks !!!

提交回复
热议问题