Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

IllegalStateException on LinearLayout.addView(View view) method call  RSS feed

Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, can somebody tell me why this happens, please read below.
I have my own class Data which extends Button. In my Activity's class I have a List<Data> which is appending with new Data object on each button click. I want to keep created objects of class Data on the screen after configuration changes, namely orientation change. So I've overrided onSaveInstanceState() and using it to restore my data in onCreate() method. In mentioned method I'm saving every Data object from the list of objects. In onCreate() method I'm trying to restore my data like this, the problem happens on line 18.

So in first case I'm getting IllegalStateException but it is working great for the second one. I don't understand the difference.

Just in case, here is my onSaveInstanceState() method:

And my Data class, but nothing special:

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!