When we have an EditText and it loses focus (to an element that doesn\'t need a keyboard), should the soft keyboard hide automatically or are we supposed to hid
my problem solved with this code (in Fragment)
LinearLayout linearLayoutApply=(LinearLayout)rootView.findViewById(id.LinearLayoutApply);
linearLayoutApply.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus)
{
hideKeyBoard(v);
}
}
});
hideKeyBoard
public void hideKeyBoard(View v)
{
InputMethodManager imm=(InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
}