Hello dudes
Small problem im sure some of you can help me with.
I got a edittext in a dialogfragment, and the keyboard pops up when i it comes in focus... now i want to remove the keyboard when hitting anywhere outside the edittext, but nomatter what i try i cant find the right eventhandler to do this.
In another activity i used this method:
public override bool OnTouchEvent(MotionEvent e) { InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(mTxtBemarkninger.WindowToken, 0); return base.OnTouchEvent(e); }
works very nice, but it does not exist in the dialogfragment - anyone know what to do here?
maybe this link (event if it's java code) : stackoverflow.com/questions/21882251/how-to-handle-touch-events-on-a-fragment
Answers
maybe this link (event if it's java code) : stackoverflow.com/questions/21882251/how-to-handle-touch-events-on-a-fragment
You sir jus saved my day...! If future people are looking at the thread, this is how i integrated the toch listener on the dialogfragment:
In the OnCreateView method:
And the OnTouchListener:
Alright bro, just implemented the class and added the method to view. I can guarantee that this perfoms as expected no more no less. You sir, have saved my life thank you very much
glad i could help you
Do you know how to detect touch outside of fragment too?
@misko101 i think you can implement the same touchlistener outside of fragments - If it is for hiding the keyboard that is!
Is it work?
@Jay2 i think it works - try it out!
@TroelsThisted Yes it works for my website Vrinsoft PTY LTD, thanks for the information.