Friday, 15 March 2013

android - EditText swipes out of visible view, but keyboard remains -



android - EditText swipes out of visible view, but keyboard remains -

in single-activity app, have viewpager has pagertabstrip. let's have 2 tabs , 2 corresponding fragments. on fragment 1 (frag1) have edittext view , on fragment 2 (frag2), there listview no editable text (just list of checkedtextviews).

when app starts, frag1 visible , focus on edittext and, thus, soft keyboard appears. no problem yet. however, when swipe other tab , frag2 slides view , frag1 no longer visible, keyboard remains though there nil on visible screen (frag2) edit. if check 1 of frag2's checkedtextviews, keyboard remains.

programmatically, how can robustly , dynamically check type of situation , hide keyboard?

you can hide keyboard on swipe event. set in tabselected method or whatever you're using switch fragments:

edittext myedittext = (edittext) findviewbyid(r.id.myedittext); inputmethodmanager imm = (inputmethodmanager)getsystemservice(context.input_method_service); imm.hidesoftinputfromwindow(myedittext.getwindowtoken(), 0);

hope helps! :d

android keyboard android-edittext hide invisible

No comments:

Post a Comment