开发者

How to open soft keyboard ontouchListener of EditText

开发者 https://www.devze.com 2023-03-04 01:49 出处:网络
I have an edittext to which I have assigned a touch listener. But when I touch the editText the soft keyboard does not pop up. I have used

I have an edittext to which I have assigned a touch listener. But when I touch the editText the soft keyboard does not pop up. I have used InputMethodManager manager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); manager开发者_运维百科.showSoftInput(roomLnEditTxt, InputMethodManager.SHOW_IMPLICIT);

but still not working.


Use SHOW_FORCED instead of SHOW_IMPLICIT

InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showSoftInput(YOUR_VIEW, InputMethodManager.SHOW_FORCED);

This will definitely solve your problem.


Add this line in the manifest

<activity android:name=".activity" android:configChanges="keyboardHidden|orientation">


public boolean onTouch(View v, MotionEvent event) {
        //your code here 

        //Return false is the trick 
        return false;

Returning false solved the problem for me .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号