JakeWharton/ActionBarSherlock — Issue #271: ABS4RC: I tryed to made SherlockMapActivity into Tab
Author: xWOLKx
Created: 2012-02-15 12:08:18+00:00
State: open

I dont know if this is the correct way, so I try to ask you because it make error when I change the tab 2 times.

I'm working on 2.3.7 device with abs4rc (14.2) and map plugin.

I try to make an activity with 2 tab, one show map:

import android.os.Bundle;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.app.SherlockMapActivity;

public class RunActivity extends SherlockMapActivity implements ActionBar.TabListener {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.empty);

getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setText("Text");
tab.setTabListener(this);
getSupportActionBar().addTab(tab);

ActionBar.Tab tabx = getSupportActionBar().newTab();
tabx.setText("Map");
tabx.setTabListener(this);
getSupportActionBar().addTab(tabx);

}

@Override
public void onTabSelected(Tab tab) {
// TODO Auto-generated method stub
if(tab.getPosition()==1)
this.setContentView(R.layout.runmap);
else
this.setContentView(R.layout.empty);
}

@Override
public void onTabUnselected(Tab tab) {
// TODO Auto-generated method stub

}

@Override
public void onTabReselected(Tab tab) {
// TODO Auto-generated method stub

}

@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}

In runmap.xml I have only

So this make this logcat when touch for the second time the map tab:

02-15 13:07:47.049: W/dalvikvm(26022): threadid=1: thread exiting with uncaught exception (group=0x40018560)
02-15 13:07:47.079: E/AndroidRuntime(26022): FATAL EXCEPTION: main
02-15 13:07:47.079: E/AndroidRuntime(26022): android.view.InflateException: Binary XML file line #9: Error inflating class
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.createView(LayoutInflater.java:518)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.actionbarsherlock.internal.ActionBarSherlockCompat.setContentView(ActionBarSherlockCompat.java:659)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.actionbarsherlock.app.SherlockMapActivity.setContentView(SherlockMapActivity.java:218)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at it.zonde.android.easytracks.RunActivity.onTabSelected(RunActivity.java:33)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.actionbarsherlock.internal.app.ActionBarImpl.selectTab(ActionBarImpl.java:523)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.actionbarsherlock.internal.app.ActionBarImpl$TabImpl.select(ActionBarImpl.java:906)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.actionbarsherlock.internal.widget.ScrollingTabContainerView$TabClickListener.onClick(ScrollingTabContainerView.java:505)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.View.performClick(View.java:2506)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.View$PerformClick.run(View.java:9112)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.os.Handler.handleCallback(Handler.java:587)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.os.Handler.dispatchMessage(Handler.java:92)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.os.Looper.loop(Looper.java:130)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.app.ActivityThread.main(ActivityThread.java:3835)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at java.lang.reflect.Method.invokeNative(Native Method)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at java.lang.reflect.Method.invoke(Method.java:507)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at dalvik.system.NativeStart.main(Native Method)
02-15 13:07:47.079: E/AndroidRuntime(26022): Caused by: java.lang.reflect.InvocationTargetException
02-15 13:07:47.079: E/AndroidRuntime(26022):	at java.lang.reflect.Constructor.constructNative(Native Method)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at android.view.LayoutInflater.createView(LayoutInflater.java:505)
02-15 13:07:47.079: E/AndroidRuntime(26022):	... 22 more
02-15 13:07:47.079: E/AndroidRuntime(26022): Caused by: java.lang.IllegalStateException: You are only allowed to have a single MapView in a MapActivity
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.google.android.maps.MapActivity.setupMapView(MapActivity.java:397)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.google.android.maps.MapView.(MapView.java:289)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.google.android.maps.MapView.(MapView.java:264)
02-15 13:07:47.079: E/AndroidRuntime(26022):	at com.google.android.maps.MapView.(MapView.java:247)
02-15 13:07:47.079: E/AndroidRuntime(26022):	... 25 more
02-15 13:07:48.869: I/Process(26022): Sending signal. PID: 26022 SIG: 9