Issue
I have a method leftup which has an onClick listener from a button. The purpose of method leftup is to do the following:
- Get an array from resources xml (Which contains names of my other activities)
- Turn array into an array list
- Remove a string from that array (The current class name)
- Convert the list back into an array
- Get a random value from that array
- Execute method goToActivity with parameter of that random value
I have spent hours on this task so far, because the logic of the code seems fine. The problem is, when I run the code, I get the infamous error:
Unfortunately, "App_Name" has stopped
Here is my code for method onClick and goToActivity:
Here is my array in the resources:
By the way, string activity state is the name of the activity :
I am sure the exception is in the method leftup, as none of the Toasts get executed, and the error happens immediately as I click on the button.
Thank you so much for all your help, I really appreciate it.
A fellow programmer,
{Rich}
Stack trace:
https://gist.github.com/anonymous/dcd63f51289aaf1a1933
Here is the stack trace because I couldn't format it, this is the git hub page.
Solution
I figured it out! After three long hours of tweaking the code, I finally got it! The arrayList had to be a linkedList. Thats it! Because, arrayList's aren't as flexible, and so one cannot remove or add items to them. I hope this answer helps, and saves you three long hours!
java.lang.UnsupportedOperationException
java.lang.reflect.InvocationTargetException
are the exceptions that happen on this issue. Just make sure to use a more flexible container. :)
{Rich}
Answered By - Ruchir Baronia
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.