android - EditText request focus not working -


i have edittext , button. on click of button want open edittext keyboard , @ same time request focus on edittext, user directly start typing in keyboard , text appears in edittext. in case when click button open keyboard, won't set focus on edittext, because of user has click edittext again write on it. issue. or suggestion.

code on click of button

m_searchedittext.requestfocus(); inputmethodmanager inputmethodmanager=(inputmethodmanager)getsystemservice(context.input_method_service); inputmethodmanager.togglesoftinputfromwindow(m_searchedittext.getapplicationwindowtoken(), inputmethodmanager.show_forced, 0); 

ensure edittext focusable in touch mode. can 2 way.

in xml:

android:focusableintouchmode="true" 

in java:

view.setfocusableintouchmode(true); 

personally don't trust xml definition of param. request focus these 2 lines of code:

view.setfocusableintouchmode(true); view.requestfocus(); 

the keyboard shoul appear on without need call inputmethodmanager.

it works in of cases. once did not work me because have lost reference object due quite heavy processing - ensure not issue.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -