I am using TabHost in my application and I need to show 2 maps in 2 different tabs. I have been able to integrate maps but the problem is when I move from one tab to another the map hangs/stucks and does not respond i.e. maps only works on one of the screen
Below is xml and class for my main layout which has TabHost
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ff0000"
>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#f00"
android:foregroundGravity="top"
android:layout_above="@android:id/tabs"
/>
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#fff"
android:tabStripEnabled="false"
>
</TabWidget>
</RelativeLayout>
</TabHost>
package com.cotechnica.alps;
import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.widget.TabHost;
import com.ankitkedia.alps.R;
public class Main extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Resources res = getResources();
TabHost tabHost = getTabHost();
TabHost.TabSpec spec;
Intent intent;
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Map1.class);
spec = tabHost.newTabSpec("home").setIndicator("Map1",
getResources().getDrawable(android.R.drawable.star_on)).setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, Map2.class);
spec = tabHost.newTabSpec("rescue").setIndicator("Map2",
getResources().getDrawable(android.R.drawable.star_big_off)
).setContent(intent);
tabHost.addTab(spec);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
I have seen many people are facing same issue but there is no proper solution available for it.
Any help would be appreciated, I can sent the sample project source if required
Regards, Ankit
This guy has a great solution
http://www.ankitkedia.com/2013/07/07/android-google-map-v2-use-multiple-maps-in-application/