My problem comes when I try to show() and hide() multiple map fragments. The map does not change using show()/hide(). the fragment can be removed or hidden but keeps in the screen(dirty).
Screen:
Here Related Issue
How can I correct this issue?
I faced a similar issue with overlapping maps belonging to different fragments.
These two thins helped me:
map:zOrderOnTop="false" on the small map.
I was using DialogFragments and calling dismiss() did the trick, but if you're using plain Fragments. you can try to remove the fragment with the FragmentManager.
What versions of Android? SDK? Maps?
Try to update: http://www.androidpolice.com/2013/07/09/google-maps-for-android-gets-updated-with-promised-interface-refresh-functionality-enhancements/
Might be a known issue: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5027&q=fragment&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal
Related
So, I'm still new on Android Fragments, but if I got it correctly, when you remove a Fragment and stack it to the back stack with addBackStack (according to Android Developer's Fragment lifecycle) you get this portion of view destroyed and when it pops up to the screen again it has to reload all it's components.
I'm specially concerned with that because one of my fragments contains a map, which is a lot of data to reload (specially if using 3G).
In that case, is it a better practice to implement hide and show to all my fragments when manipulating them?
I just see a little problem there because I'd have to create my own stack to know the order they were called and have to be shown again.
Well, it's now a huge problem, but I wanted to hear from someone if it is worth putting effort on it to implement this approach instead of the existing back stack.
Thanks in advance!
Using the ´attach´ and ´detach´ operations are another way around to your problem. The fragment instances will still exist, but deactivated and not visible, and you can recover them using the FragmentManager
If one of your fragments contain google map, it's better to use show/hide operations with the fragment views in order to avoid google map black flickering bug. Check my answer: https://stackoverflow.com/a/25206078/2999943
I am using a single activity with multiple frgmetns where each holds a MapView in its fragment.
This is a reported bug, that i occurs on 4.0.4 android (probably on 4.0 also) but works properly on higher versions.
https://code.google.com/p/gmaps-api-issues/issues/detail?id=5027
Multiple maps v2 in TabActivity
When a new fragment is added both maps show. If a third fragment is added all tree maps are shown. I have tried applying the hideStupidMaps fix as discussed above but it provides no result( i have added calls to hide/show maps in onResume/onPause).
I have also added calls to hide the previous map before calling FragmentManager and its transaction but no result.
I have tried setting MapView visibility to INVISIBLE but also no result, the map previos map still shows, like no refresh is happening?
Is there a way to set zIndex to MapView? I know you can set z index when using MapFragment through GoogleOptions but i cant find an option to do that with MapView?
GoogleMapOptions options = new GoogleMapOptions();
options.zOrderOnTop(true);
fragmentMap = SupportMapFragment.newInstance(options);
I have managed to get it working. The problem was that i was actually calling hideStupidMaps after fragment transaction, and on 4.0.4 android it didnt have any effect while it worked on 4.1. I moved the call before the Fragment transaction and it worked. The only downfall is that for a moment the user can see the map disappear before Fragment animation starts.
I have also added a OnBackStackChangedListener where i would show the previously hidden map when returning via back button/action bar.
Hope it helps someone, and a piece of advise, avoid multiple maps in fragments if you can...
Basically what i am trying to do is
Tab1 -> Organisation Map Fragment
Tab2 -> City Map
How should I go about doing this. I tried following some tutorials but it gives me the error "You are allowed to have single MapView in a MapViewActivity". Can some one please help me out
It's not possible to do this. As the message says, only one map per Activity.
As Joe and the error message says, you can only have one mapview in a single activity.
What you could do (if you still want to use tabs) is just not change the fragment when the tab changes, and instead reload the map with different data.
Google released the Map API Version 2. This finally allows to use a MapFragment and a SupportMapFragment. This allows adding Maps to ViewPagers and to Activities that do not extend MapActivity. It should also allow you to have multiple maps in one Activity
is it possible to insert one Android fragment into another? I haven't noticed any information in SDK about this.
The behaviour of nested fragments is undefined, see #hackbod's answer here
Basically, this question Popup/Overlay screen in android honeycomb
but the answer provided doesn't explain what to do with the fragment inside the FrameLayout
The fragment in the XML is the underlying activity. In the case of that question, it would be the fragment that is running the map.
Please be more specific with your question to help people who use the search feature and Google.