android - expandablelistview ArrayIndexOutOfBoundsException -


i trying implement expandablelistview 2 different layouts, far took me while make 1 viewgroup use layout , 2 other viewgroups use other. , far appearance what's needed, when click twice on same viewgroup or on 2 different viewgroups app crashes arrayoutofbounds error. code

@override public int getchildtype(int groupposition, int childposition) {      int result;     if (groupposition == 0)     {         log.d("getchildtype","parent " + groupposition + " detected. returning 0");         result = 0;     }     else     {         log.d("getchildtype","parent " + groupposition + " detected. returning 1");         result = 1;     }     return result; }  @override public view getchildview(final int parentposition, final int childposition, boolean islastchild, view convertview, viewgroup parent) {      log.d("status","parent : "+parentposition + "child : " + childposition + "view : "+convertview + "viewgroup : "+parent);     final string child_title = (string) getchild(parentposition, childposition);     int itemtype = 5;     if (convertview == null)     {         layoutinflater inflater = (layoutinflater) ctx.getsystemservice(context.layout_inflater_service);         itemtype = getchildtype(parentposition,childposition);          switch (itemtype)         {             case 0:                 convertview = inflater.inflate(r.layout.activities2_child_layout, parent, false);                 break;             case 1:                 convertview = inflater.inflate(r.layout.activities2_child2_layout, parent, false);                 break;         }     }     if (itemtype == 0)     {         textview child_textview = (textview) convertview.findviewbyid(r.id.activities2_child_txt);         final imageview img_likes = (imageview) convertview.findviewbyid(r.id.activities2_img_like);         final imageview img_dislikes = (imageview) convertview.findviewbyid(r.id.activities2_img_dislike);         child_textview.settext(child_title);     }     else if(itemtype == 1)     {         textview child_textview = (textview) convertview.findviewbyid(r.id.activities2_child2_txt);         child_textview.settext(child_title);     }        return convertview; } 

error

    06-15 11:54:14.753  29578-29578/android.omar.com.slidingtab e/androidruntime﹕ fatal exception: main         java.lang.arrayindexoutofboundsexception: length=2; index=2 06-15 12:02:53.343  31025-31025/android.omar.com.slidingtab w/dalvikvm﹕ threadid=1: thread exiting uncaught exception (group=0x41eb1378) 06-15 12:02:53.393  31025-31025/android.omar.com.slidingtab e/androidruntime﹕ fatal exception: main     java.lang.arrayindexoutofboundsexception: length=2; index=2             @ android.widget.abslistview$recyclebin.addscrapview(abslistview.java:6444)             @ android.widget.listview.layoutchildren(listview.java:1603)             @ android.widget.abslistview.onlayout(abslistview.java:2106)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.relativelayout.onlayout(relativelayout.java:953)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.framelayout.onlayout(framelayout.java:460)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.linearlayout.setchildframe(linearlayout.java:1687)             @ android.widget.linearlayout.layoutvertical(linearlayout.java:1545)             @ android.widget.linearlayout.onlayout(linearlayout.java:1450)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.framelayout.onlayout(framelayout.java:460)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.linearlayout.setchildframe(linearlayout.java:1687)             @ android.widget.linearlayout.layoutvertical(linearlayout.java:1545)             @ android.widget.linearlayout.onlayout(linearlayout.java:1450)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.widget.framelayout.onlayout(framelayout.java:460)             @ android.view.view.layout(view.java:13923)             @ android.view.viewgroup.layout(viewgroup.java:4472)             @ android.view.viewrootimpl.performlayout(viewrootimpl.java:1876)             @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1697)             @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:1004)             @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4223)             @ android.view.choreographer$callbackrecord.run(choreographer.java:725)             @ android.view.choreographer.docallbacks(choreographer.java:555)             @ android.view.choreographer.doframe(choreographer.java:525)             @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:711)             @ android.os.handler.handlecallback(handler.java:615)             @ android.os.handler.dispatchmessage(handler.java:92)             @ android.os.looper.loop(looper.java:213)             @ android.app.activitythread.main(activitythread.java:4787)             @ java.lang.reflect.method.invokenative(native method)             @ java.lang.reflect.method.invoke(method.java:511)             @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:789)             @ com.android.internal.os.zygoteinit.main(zygoteinit.java:556)             @ dalvik.system.nativestart.main(native method) 

hoping fast answer. lot in advance
omar

i think should override getchildtypecount() , return 2

   @override    public int getchildtypecount(){         return 2;     } 

hope help.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -