I hope I can explain this properly. I'm making an android app that, when you open it, it connects to a JSON server, pulls down the data (GPS coords) and dynamically creates a "menu" based on what it received (View1). This will consist of a few buttons, which when clicked, will load a MapView (View2) with the coords gotten from the JSON represented as markers on the map.
I start off with setContentView(R.layout.menu)
then get the data, onbuttonClick I load setContentView(R.layout.map)
and draw the markers. The problem is, I have an onLocationChangedListener
that goes through the code to set up the menu initially. When it tries to build the menu when the mapView
is open, I get a force close. Unfortunately, this code also updates the user location and the locations of the overlays and re-draws the map.
My question is: Can I do a check on a layout to say something like if (isActive)
so that I can perform actions only if the current view is in focus?
OR should I scrap the whole thing and start again with a better layout? (Suggestions welcome)
Summary::: I have 2 views (menu,map). Need access to same data across both. Currently works with setContentView()
but gives me a Force Close when actions are performed on inactive view.