android - adjustpan not work in expandablelistview when click second time for the same edittext -
first time,click edittext in expandablelistview,the whole layout scrolled ,and user can see edittext. click softkeyboard finish collapse softkeyboard , click edittext second time ,softkeyboard show, whole layout not scrolled, , user cannot see edittext. find in listview ,too.i searched long time , 1 says anroid bug? there replacement?
by many days spent,i found solution. hack.
- put edittext wrapped in linearlayout.
detect softkeyboard show visiable layout change.
public final void setkeyboardlistener(final onkeyboardvisibilitylistener listener) { final view activityrootview = getwindow().getdecorview() .findviewbyid(android.r.id.content); activityrootview.getviewtreeobserver() .addongloballayoutlistener(new ongloballayoutlistener() { private final rect r = new rect(); private boolean wasopened; @override public void ongloballayout() { activityrootview.getwindowvisibledisplayframe(r); int heightdiff = activityrootview.getrootview().getheight() - (r.bottom - r.top); boolean isopen = heightdiff > 100; if (isopen == wasopened) { return; } wasopened = isopen; listener.onvisibilitychanged(isopen); } }); } public interface onkeyboardvisibilitylistener { void onvisibilitychanged(boolean visible); }
when softkeyboard show,pick textview in listview item or expandablelistview child item. set text thing, whole view scrolled normal! code this:
activity.setkeyboardlistener(new onkeyboardvisibilitylistener() { @override public void onvisibilitychanged(boolean visible) { if (visible) { message message = new message(); message.what = 999; handler.sendmessage(message); } } }); private handler handler = new handler() { @override public void handlemessage(message msg) { if (msg.what == 999) { if (mdatamap.size() > 0) { (int = 0; < expandablelistview.getchildcount(); i++) { view v = expandablelistview.getchildat(i); textview tvcannotsee = (textview) v.findviewbyid(r.id.tv_cannot_see ); if (tvcannotsee != null) { //this key hack make adjuspan work! , scroll whole view normal tvcannotsee.settext("this android bug"); return; } } } return; } super.handlemessage(msg); } };
this textview show invisble user proper purpose.if expandablelistview , edittext in childitem,the textview update must in childitem.
Comments
Post a Comment