fitnesskim / tree-view-list-android

Automatically exported from code.google.com/p/tree-view-list-android
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

java.lang.ArrayIndexOutOfBoundsException #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, I think you have an error in the the AbstractTreeViewAdapter class. I 
was getting a java.lang.ArrayIndexOutOfBoundsException.
When I would create a large tree, and scroll way down the list I would get the 
exception.  I found an article on stack overflow that seemed like the same 
issue.

http://stackoverflow.com/questions/3017496/arrayadapter-and-listview-arrayindexo
utofboundsexception

I don't think it is good to override the getViewTypeCount() method in the way 
that the AbstractTreeViewAdapter class is.

In my project I commented out this method, and It seemed to fix the Exception.

//    @Override
//    public int getViewTypeCount() {
//        return numberOfLevels;
//    }

I could be wrong but it seemed to help me. you might want to make a really big 
tree to see if you get the same exception.

Original issue reported on code.google.com by christop...@gmail.com on 18 Aug 2011 at 12:42

GoogleCodeExporter commented 9 years ago
Do you happen to have a stacktrace of this issue? And another question - do you 
change dynamically the content of the tree (and specifically the depth of it? 
Because it might be caused by that.....

Original comment by ja...@potiuk.com on 8 Sep 2011 at 2:43

GoogleCodeExporter commented 9 years ago

The user can load different content in the tree, but the exception only happens 
when I am scrolling though the tree list. When the crash happens I'm not 
changing any of the content of the tree.

here's the stack trace

java.lang.ArrayIndexOutOfBoundsException
    at android.widget.AbsListView$RecycleBin.addScrapView(AbsListView.java:3523)
    at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2445)
    at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:2313)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4203)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
    at dalvik.system.NativeStart.main(Native Method)

Original comment by christop...@gmail.com on 8 Sep 2011 at 9:37

GoogleCodeExporter commented 9 years ago
Overriding view count is not a problem on its own. this is is the only way to 
use different views at different tree levels (which was my intention). When you 
create adapter you specify how many levels the tree should be (numberOfLevels 
parameter) at the time when you construct the adapter. If you happen to have 
more levels in the tree than specified at creation time - this is exactly when 
this error happens ...  I think this is your problem really, because they way 
adapter is written - the viewtypecount cannot change (it is set in constructor) 
and the SO link mentions about dynamic count changing .....  Can you post your 
initialisation code and see more closely how deep your tree can become?

Original comment by ja...@potiuk.com on 10 Sep 2011 at 6:49