The ExpandableList View crashed on scrolling more then 30 records only in Nexus running “ice cream sandwich Android OS 4.0). This problem only occurred in my Nexus phone. It works fine in my emulator even run it on Andriod 4.0 with more then 30 records.
I have used the android inflate feature (to render the layout from XML file) in getGroupView and getChildView() method of the BaseExpandableListAdapter class. If
If I render the getChildView() and getGroupView() function using the dynamic TextView then it works fine.
The problem only generated during the scroll and also in Android OS 4.0 (nexus) phone otherwise it works fine.
I got following error:
java.lang.OutOfMemoryError
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:483)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:549)
at com.android.myexample.Custom$MyExpandableListAdapter.getChildView(Custom.java:681)
at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:450)
at android.widget.AbsListView.obtainView(AbsListView.java:2012)
at android.widget.ListView.makeAndAddView(ListView.java:1772)
at android.widget.ListView.fillUp(ListView.java:705)
at android.widget.ListView.fillGap(ListView.java:645)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4546)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:3813)
at android.os.Handler.handleCallback(Handler.java:605)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4340)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
the error occured on following code…
childImg.setImageBitmap(BitmapFactory.decodeStream(getAssets().open((childListDataBean.get(groups.get(groupPosition)).get(childPosition).imageId))));
Finally I fixed this bug by disabling the scrolling catch of the expandablelistview using following…………………………………………………..