android - Keyboard is not showing on single click -
i trying show keyboard onclick not showing automatically (keyboard in hidden state in manifest) working on double click... here source.
search.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { search_friends.setvisibility(view.visible); //my_friends.setvisibility(view.gone); search_friends.requestfocus(); if(search_friends.hasfocus()) { getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_visible); } else { getwindow().setsoftinputmode(windowmanager.layoutparams.soft_input_state_hidden); } } });
i want on single click...
this method, made util class, use in every project , works:
/** * hide ed == null <br/> * show ed !=null * * @param context * activity * @param ed * edittext */ public static void hideorshowsoftkeyboard(activity context, edittext ed) { try { inputmethodmanager inputmanager = (inputmethodmanager) context.getsystemservice(context.input_method_service); if (ed != null) { inputmanager.showsoftinput(ed, 0); } else { inputmanager.hidesoftinputfromwindow(context.getcurrentfocus().getwindowtoken(), inputmethodmanager.hide_not_always); } } catch (nullpointerexception e) { logservice.log(tag, "nullpointerexception"); } }
// in implementation
@override public void onclick(view v) { search_friends.setvisibility(view.visible); //for showing keyboard appnameutils.hideorshowsoftkeyboard(this,search_friends); }
Comments
Post a Comment