android - EditText in ExpandableListView - Retaining focus when soft keyboard is opened -


i have expandablelist multiple groups, , each group contains child of different type (different layouts). have several activities similar structure, different child views, , decided write custom adapter it. adapter works part, except couple of problems:

  1. typing text in child view next impossible. appears edittext loses focus after each character typed. have attached screenshot illustrate behaviour.
  2. when groups expanded / collapsed, after couple of times, text in textviews seem disappear, first letter of first word in each view appearing. somehow appears though layout parameters miscalculated somehow.

here screenshots: edittext - jittery typing textview - layout of text in textview

and here code adapter:

public class genericexpandablelistadapter extends baseexpandablelistadapter {      private context context;     private string[] groups;     private view[] children;      public static interface expandablelistitemclicklistener {         public void onclick(view view, int groupid, int itemid);     }      public genericexpandablelistadapter(context context, string[] groups, int[] children) {         if(groups.length != children.length) {             throw new illegalargumentexception("items must have same length groups.");         }         this.context = context;         this.groups = groups;          layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);         this.children = new view[children.length];         for(int = 0; < children.length; i++) {             this.children[i] = inflater.inflate(children[i], null);         }     }      public genericexpandablelistadapter(context context, string[] groups, view[] children) {         if(groups.length != children.length) {             throw new illegalargumentexception("items must have same length groups.");         }         this.context = context;         this.groups = groups;         this.children = children;     }      @override     public object getchild(int groupposition, int childposition) {         return children[groupposition];     }      @override     public int getchildtypecount() {         return children.length + 1;     }      @override     public int getchildtype(int groupposition, int childposition) {         return groupposition;     }      @override     public long getchildid(int groupposition, int childposition) {         return childposition;     }      @override     public view getchildview(final int groupposition, final int childposition,             boolean islastchild, view convertview, viewgroup parent) {         if(convertview != null) {             return convertview;         }         return children[groupposition];     }      @override     public int getchildrencount(int groupposition) {         return 1;     }      @override     public object getgroup(int groupposition) {         return groups[groupposition];     }      @override     public int getgrouptypecount() {         return 1;     }      @override     public int getgroupcount() {         return groups.length;     }      @override     public long getgroupid(int groupposition) {         return groupposition;     }      @override     public int getgrouptype(int groupposition) {         return 0;     }      @override     public view getgroupview(int groupposition, boolean isexpanded,             view convertview, viewgroup parent) {          if(convertview != null) {             ((textview) convertview).settext(getgroup(groupposition).tostring());             return convertview;         }         // layout parameters expandablelistview         abslistview.layoutparams lp = new abslistview.layoutparams(                 viewgroup.layoutparams.match_parent, 64);          final textview textview = new textview(context);         textview.setlayoutparams(lp);         // center text vertically         textview.setgravity(gravity.center_vertical | gravity.left);         // set text starting position         textview.setpadding(50, 0, 0, 0);         textview.settext(getgroup(groupposition).tostring());         return textview;     }      @override     public boolean hasstableids() {         return true;     }      @override     public boolean ischildselectable(int groupposition, int childposition) {         return false;     }  } 

i had similar problem.

add in manifest file , see if works. did me.

android:windowsoftinputmode="adjustpan"  

within activity tag

<activity         android:name=".mainactivity"         android:label="@string/app_name"          android:windowsoftinputmode="adjustpan"> 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -