For my application I have to achieve something near from a launcher : I have to provide the ability to add, remove, resize and drag n drop dynamically some UI elements (let's call them "widgets", but they are not Android AppWidgets) . It works pretty fine, but one of these "widgets" contains a MapFragment, and I am not able to add it twice, neither to remove it and add it again.
For the moment, each "widget" is inherited from FrameLayout. The MapFragment is loaded from a xml. The problem is that we can't set a Fragment id by code, and if I do it in the xml, I have obviously the same id for all of my maps. So I get this exception :
03-20 09:55:35.078: E/AndroidRuntime(19507):
Caused by: java.lang.IllegalArgumentException:
Binary XML file line #24: Duplicate id 0xffffffff, tag map,
or parent id 0xffffffff with another fragment for
com.google.android.gms.maps.MapFragment
Here is the code for the fragment :
...
<fragment
android:tag="map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
...
View.inflate(getContext(), layout, R.layout.widget_map);
So here I am, completely stuck ^^. I already search through stackoverflow and the internet without founding a solution.
Moreover, I'm using the Android Maps API V2, and I get some GC printing in the console each time I change the orientation of the screen (so when the map is redrawn), must I worry about them ?
03-20 10:02:41.820: D/dalvikvm(19650): GC_CONCURRENT freed 1929K, 17% free 11579K/13940K, paused 3ms+4ms, total 44ms
03-20 10:02:42.250: D/dalvikvm(19650): GC_CONCURRENT freed 382K, 14% free 12123K/13940K, paused 3ms+13ms, total 67ms
03-20 10:02:42.250: D/dalvikvm(19650): WAIT_FOR_CONCURRENT_GC blocked 51ms
03-20 10:02:42.328: D/dalvikvm(19650): GC_CONCURRENT freed 2114K, 21% free 11099K/13940K, paused 2ms+2ms, total 45ms
03-20 10:02:42.328: D/dalvikvm(19650): WAIT_FOR_CONCURRENT_GC blocked 32ms
Any advice would be welcome !