I've done many tutorials (in my quest to find the answer to this question) so I'm basically familiar with how to draw basic shapes as well as bitmap images on a view using a canvas as well as on a surface view. The problem is, every tutorial I find is the same - it tells me to set content view to the view (or surface view).
But the whole point is that I want to draw on a view within a greater layout, so that my buttons, textboxes, etc are all visible next to my surface view (or other view within my main view) and still be able to draw on my view.
Probably the same(ish) way as doing as a content. A couple of things to thing about:
1) Make sure the view you intend to draw on has a predefined size. If not, it may (will likely) be shrunk to 0px wide and 0px tall.
2) You may find it easiest to position things with a RelativeLayout to avoid unwanted resizing
3a) You may find it easier to make the layout with the surface view in it, then get it out of the view using findViewById()
3b) Alternatively, you should put a placeholder FrameLayout where you want the surface view, then get the FrameLayout using findViewById() and adding your surface view to the frame
If you are having problems, show the layout, a simple version of the code, and a screenshot of the results, and details about the difference between expectations and results so we can help you with the issue.
As you can see, in the above code the tutorial says to change the content view to myView, but I want the content view to be the main layout.
The problem is, once I've changed the content view to the main layout, I have no idea how to "connect" that MyView class to my View, which is called "viewMap". I just want the drawing that is happening in the myview class to happen to my view object, "viewMap".
When I figure out how to do that, I'll take your advice on the other things, Steve Luke, thanks!
I've made a small breakthrough, but every time I click the button my app crashes.
At the very least I've "connected" my View to the MyView class in a way that seems to be basically correct...I just don't know what I'm missing? How can I get it to draw on the view and not crash when the button is pressed?
Aigh, I'm a bit of a noob when it comes to Android programming. My app relies on GPS to function so I find it faster to just debug by installing it on my phone each time and then running it rather than using the emulator. My emulator is extremely slow and I'm not sure how to get the GPS and saving to SD card things to work properly when using the emulator. Using my phone, however, I don't know how to get the logcat information.
First thing you need to do is enter Developer Mode (this is typically done in the Settings menu but varies by Android version and model so search to find out how to do it). then turn on USB debugging. When debugging is on, run the app from your IDE using the phone, then change to the LogCat view.