I'm using a SearchView to enter a number from a bluetooth barcode reader.
The SearchView is focused as follows:
svActListaPedidosFragmento.setFocusable(true);
svActListaPedidosFragmento.setIconified(false);
The problem is that when the SearchView is focused, the software keyboard appears and I want to hide it.
The method to hide the keyboard I understand very well
The problem is that I can not find an event that tells me that the keyboard has appeared.
In a previous thread someone told me that I can use the OnClickListener event for SearchView, but I discovered that this event happens BEFORE the keyboard is displayed.
Thanks for any comments or suggestions.
Just Use this and pass your editText and boolean type param to show or keyboard
private void inputModeChange(final EditText editText, final boolean showKeyboard) {
editText.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
if (showKeyboard) {
InputMethodManager keyboard = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.showSoftInput(editText, 0);
} else if (showKeyboard == false) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
}
}, 50);
}
Hope it will Help.