• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to save finger drawing on orientation changes?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! I've got the following problem - there's a custom View which is used for drawing and is hosted in MainActivity. After screen orientation changes the drawing disappears. Can anyone please give me a hint about it. Here's my view:

 
Dmitri Pietel
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I thought I would store EventList in ArrayList, put it in Bundle and restore in onSaveInstanceState:



Getting NPE in this line: when calling performTouchEvent() after rotation
 
Saloon Keeper
Posts: 4038
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to save and restore all instance variables. Otherwise the objects have their default value, which is null.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!