android - How to automatically enter in edit mode in a search? -


i've implemented classic search feature in action bar when click on search menu button, search edittext appears have click on enter in edit mode whereas of application directly enter in edit mode after displaying edittext.

how fix it?

my code just:

@override public void oncreateoptionsmenu(menu menu, menuinflater inflater) {     // place action bar item searching.     menuitem item = menu.add("search");     item.seticon(android.r.drawable.ic_menu_search);     item.setshowasaction(menuitem.show_as_action_if_room             | menuitem.show_as_action_collapse_action_view);     msearchview = new fragment_sitemanager.mysearchview(getactivity());     msearchview.setonquerytextlistener(this);     msearchview.setoncloselistener(this);     msearchview.seticonifiedbydefault(true);     msearchview.setqueryhint(getstring(r.string.label_tvgiveposition));     item.setactionview(msearchview);  }  @override public boolean onoptionsitemselected(menuitem item) {      return super.onoptionsitemselected(item); } 

edit

i tried following code doesn't work:

@override public boolean onoptionsitemselected(menuitem item) {      view view = msearchview.findfocus();      inputmethodmanager imm = (inputmethodmanager) activity.getsystemservice(context.input_method_service);     imm.showsoftinput(view, inputmethodmanager.show_forced);     return super.onoptionsitemselected(item); } 

regards,

according android docs, searchview has edittext behavior shouldn't need force softkey. seems issue is in onoptionitemselected() when should in oncreateoptionmenu(). if must, code force below. take careful long @ links @ bottom of post.

  1. get inputmethodmanager
  2. call method show soft keys , pass search view , flag, show_forced
  3. done!

    inputmethodmanager imm = (inputmethodmanager) getsystemservice(context.input_method_service); imm.showsoftinput(msearchview, inputmethodmanager.show_forced); 

look @ class more info. @ android docs on searchview.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -