Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IllegalStateException on LinearLayout.addView(View view) method call

 
You Gin
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic