Search code examples
androidandroid-edittextandroid-keypad

Keep the numeric keypad open through out activity life


I have a screen which asks user to enter PIN. I have 4 separate boxes & each box will have only one digit. So I want to keep the Numeric keypad open through out the life of an activity. I am able to force keypad open up on activity starts. But On presses back button it gets hidden.


Solution

  • Can you set this as part of your activity section on your manifest file :

    android:windowSoftInputMode="stateAlwaysVisible"
    

    you could try something like this :

    public class EditView extends EditText {
    
        public EditView (Context context, AttributeSet attrs) {
            super(context, attrs);
        }
        @Override
        public boolean onKeyPreIme(int keyCode, KeyEvent event) {
            return true;
        }
    }