Skip to content Skip to sidebar Skip to footer

How To Automatically Pop-up Keyboard?

I have Edit Text field where I have to input a password, but I have to push this field. How to automatically pop-up keyboard without touching the Edit Text? There is an Edit text x

Solution 1:

Use this code in the point where you want to display the keyboard (may be in oCreate?)

    EditText myEditText = (EditText) findViewById(R.id.editPasswd);
    ((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
        .showSoftInput(myEditText, InputMethodManager.SHOW_FORCED);

Solution 2:

I'm assuming you mean to automatically pop it up when the activity starts. If so, adding this to the activity-tag in the manifest solved it for me (unlike Erfan's answer):

android:windowSoftInputMode="stateVisible"

Solution 3:

One line in the Java class:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);

Post a Comment for "How To Automatically Pop-up Keyboard?"