How to override the OnDraw Method?

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!

Answers


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.


Need Your Help

Rerendering partial view at a JavaScript event in Ruby on Rails

javascript ruby-on-rails partial-views renderpartial

I would like to rerender some partial views in Ruby on Rails at a specific JavaScript event. Do you guys know how I could do that?

Limiting the files that can be selected using Open FIle Dialog box

c# .net winforms visual-studio-2010

I got this C# windows forms application where I load either a XML file or a CSV file for some task operations. I got a Browse button. When I click the Browse button, Open File Dialog box appears a...