I have 2 edit text and a seekbar within an activity. I would like to prevent the soft keyboard from popping up when touching the seekbar even if an edit text has the focus. I also tried to force the seekbar focus but it did not work either.
I have tried to hide the soft keyboard on the three SeekBar methods (onProgressChanged
, onStopTrackingTouch
and onStartTrackingTouch
), and also one by one but this does not work.
Is it possible and how to achieve that ?
Thx
private void hideSoftKeyboard(){
// HIDE SOFTKEYBOARD
InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
/**
* SEEKBAR Start tracking
*/
public void onStartTrackingTouch(SeekBar seekBar) {
// HIDE SOFTKEYBOARD
hideSoftKeyboard();
}
Oups sorry, I found the solution after many searches.. Here is it :
private void hideSoftKeyboard() {
// HIDE SOFTKEYBOARD
//InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
// imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mSeekBar.getWindowToken(), 0);
}