Enthusiast
Enthusiast

Reputation: 249

Way to hide softkeypad provided not effecting the features of the edittext in android

I have hidden soft keypad because I have custom keypad on the app. When the edittext is clicked, soft keypad shouldn't pop up. So, I have tried so many ways from the sources, but nothing worked except the editText.setFocusable(false); . But now the problem is edittext is not getting highlighted when I clicked it and even cursor is not visible. I have tried using InputManager, android:windowSoftInputMode="stateAlwaysHidden in the manifest and referred many like link 1 , link 2 etc., but these techniques atleast don't even hide the soft keypad on my app. Finally I got this through setFocusable, but there is a highlighting problem and cursor invisible problem and even requestFocus() in the onClickListener didn't work. Can someone give exact solution for this problem? Code snippet is appreciated.

Upvotes: 11

Views: 368

Answers (5)

Omid Aminiva
Omid Aminiva

Reputation: 667

how about if you editText.setOnTouchListener and when you create the new OnTouchListener do nothing something like:

editText.setOnTouchListener(new OnTouchListener(){

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true;
    }

});

Upvotes: 1

user1682446
user1682446

Reputation:

Try this:

InputMethodManager imm = (InputMethodManager)getSystemService( Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFomWindow( edittext.getWindowToken(), 0);

Upvotes: 1

Talal Qaboos
Talal Qaboos

Reputation: 48

You ddont need to add any method in menifist. just add this code.. It will automaticlly hide when you click on button to get value.

Want to hide softkeyboard use this code in your click listener method.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFomWindow(edittext.getWindowToken(),0);

i hope this code work fine.

Upvotes: 1

Ashish Agrawal
Ashish Agrawal

Reputation: 1977

please use this in manifest:

android:configChanges="orientation|keyboardHidden"         
android:windowSoftInputMode="stateHidden" 

Upvotes: 1

Kiran Android
Kiran Android

Reputation: 286

Try this one in activity class

getwindow().setsoftInputMode(winowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

This one is avoiding of soft key pad

Upvotes: 1

Related Questions