Android - Checkboxes in ListView lose their status when user open/hide soft keyboard -


i implemented custom arrayadapter manage data , show in listview. code of custom adapter:

private class viewholder{      user user;     checkbox check; }  @override public view getview(final int position, view convertview, viewgroup parent) {     final viewholder holder=new viewholder();     layoutinflater inflater = (layoutinflater) getcontext()             .getsystemservice(context.layout_inflater_service);      user c = getitem(position);      if(convertview==null)         convertview=new usercheckablerow(getcontext(),c.getchecked());     checkbox name = (checkbox)convertview.findviewbyid(r.id.usercheckbox);       name.settext(c.getname());     holder.user=c;     holder.check=name;     name.setchecked(holder.user.getchecked());     convertview.settag(holder);     name.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             viewholder holder=(viewholder)((view)v.getparent().getparent()).gettag();             checkbox ck=holder.check;             user c=(user) holder.user;             c.setchecked(ck.ischecked());         }     });     return convertview; } 

in activity user fills fields , check checkboxes; when check them , open/close keyboard continue filling other fields, checkbox status lost , these become unchecked.

what tried (and didn't work):

  • set onfocuschangedlistener edittext fields intercept when focus;

  • set onkeylistener edittext fields intercept keycode_back event;

  • implement onbackpressed();

  • implement globallayoutlistener (how check visibility of software keyboard in android?) intercept when keyboard open, code checkboxes unclickable because of continuous refreshing list;

  • implement onconfigurationchanged() listen keyboardhides|screenresize , callback event can intercept hard keyboard , didn't work;

how can manage situation?

read , try understand example: http://www.javacodegeeks.com/2013/09/android-viewholder-pattern-example.html

also viewholder class should "static".


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -