Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayOutOfBoundsException when adding items #24

Closed
ghost opened this issue Aug 19, 2014 · 5 comments
Closed

ArrayOutOfBoundsException when adding items #24

ghost opened this issue Aug 19, 2014 · 5 comments

Comments

@ghost
Copy link

ghost commented Aug 19, 2014

Hi! I've copied the exact same example from README.md and everything works with it. But when I add items in arrays.xml the app crashes with ArrayOutOfBoundsException. Here's the logcat:

Caused by: java.lang.ArrayIndexOutOfBoundsException: length=12; index=12
at android.content.res.TypedArray.getResourceId(TypedArray.java:571)
at org.arasthel.googlenavdrawermenu.views.GoogleNavigationDrawer.configureWithTypedArray(GoogleNavigationDrawer.java:235)
at org.arasthel.googlenavdrawermenu.views.GoogleNavigationDrawer.(GoogleNavigationDrawer.java:89)

@jmartinesp
Copy link
Owner

Could you attach the arrays that you are using? Both strings and drawables if you are using them.

@ghost
Copy link
Author

ghost commented Aug 20, 2014

I've copy/pasted the example from README and it crashes if I add anything more in it, it's enough to add 1 more entry to crash...

<string-array name="navigation_main_sections">
    <item>Now Playing</item>  // changed name
    <item>Songs</item>  // changed name
    <item>Genres</item> // added this entry
</string-array>

<string-array name="navigation_secondary_sections">
    <item>Settings</item>
    <item>Info</item>
</string-array>

<array name="drawable_ids">
    <item>@drawable/ic_home</item>
    <item>@drawable/ic_other</item>
</array>

The icons are default, didn't even touch that part...

@jmartinesp
Copy link
Owner

You have 3 list items and only 2 drawables, when it tries to get the drawable that's missing, the app crashes. I should add a better exception for this case.

I just tried the same code as you adding another drawable and it worked fine. With only two, it crashed.

@ghost
Copy link
Author

ghost commented Aug 20, 2014

Oh, I thought you set 1 drawable for main list and 1 for secondary that repeat themselves thru the list because in the example you have 2 drawables set for 2 items in main list and none for secondary so I just assumed that first drawable is for main list and second for secondary...
Anyway this "issuse" is now good for closing :)

@jmartinesp
Copy link
Owner

Then I should explain that better in the README, too 😄. Each drawable matches one entry. You can set an array of ids for main and another for secondary items, but it must be an array. I'm closing this as it's not a real bug, but I'll try to get some time and add better documentation and an exception. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant