0

I have an OnDraw method which draws a set of rectangles [ like an indoor map].On the touch event, a new Activity Intent is called.After the new activity is called,I want to know, how to redraw the rectangles on the buttonClick event( showing a new path in the map).

Below i have mentioned what ive done so far.

  • 1.I have drawn a map on a surface view using DrawRect()
  • 2.Then I catch the rectangle coordinates onTouch event
  • 3.Using a webService, i calculate a shortest path to a location
  • 4.After catching the touched rectangle coordinates, i jump in to a new activity
  • 5.I want to re draw my map(including the path) when i click A button on the new activity

Please give me an idea about how to override and redraw the On Draw method???

Thank you!

Ruby
  • 752
  • 2
  • 8
  • 23

1 Answers1

0

If I understand correctly, I think you just need to call View.invalidate() on your view to cause it to re-draw. I'm confused as to why you are switching activities, however. It sounds like you should just do your webservice call in an AsyncTask and then in it's onPostExecute(), call invalidate() on your view to cause it to re-draw with whatever data you have now given it.

However, it sounds like you may not have actually implemented your own View class but instead are drawing directly to the surfaceView? I would read up on how to make your own subclass of View. It's really not that hard.

mmeyer
  • 3,598
  • 1
  • 19
  • 22