Show Google Maps V2 markers based on selected tab
I'm using Fragments and ViewPager to show two tabs inside my app. There's
a map inside the main activity:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</android.support.v4.view.ViewPager>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="@layout/activity_map"
/>
I would like to show different set of markers on map in each tab. First
tab is loading them from local db and the second one from the remote
server. I've tried placing the logic inside onCreateView in Fragment but
they both get called immediately when the activity starts, not when one of
them is selected, so markers aren't replaced on tab select. How should I
proceed?
No comments:
Post a Comment