I am trying to paste MapViewin ActionBar Tab, but I could not solve the problem even when searching on Google.
Here are the main activities:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fm = getSupportFragmentManager();
fm.beginTransaction().add(android.R.id.content, GigLoader.GigLoaderListFragment.newInstance()).commit();
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ActionBar.Tab tab1 = getSupportActionBar().newTab().setText("Geo").setTabListener(this);
ActionBar.Tab tab2 = getSupportActionBar().newTab().setText("Lista").setTabListener(this);
getSupportActionBar().addTab(tab1);
getSupportActionBar().addTab(tab2);
}
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
if (tab.getPosition() == 0) {
fm.beginTransaction().add(android.R.id.content, GigLoader.GigLoaderListFragment.newInstance()).commit();
}
else {
fm.beginTransaction().add(android.R.id.content, GeoGigLoader.GeoGigMapFragment.newInstance()).commit();
}
}
And here is the code GeoGigLoader:
public class GeoGigLoader extends FragmentMapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public static final class GeoGigMapFragment extends Fragment {
static GeoGigMapFragment newInstance() {
GeoGigMapFragment map = new GeoGigMapFragment();
return map;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.map_gigs, container, false);
MapView mapView = (MapView)view.findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
return view;
}
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
FragmentMapActivityis a library from actionbarsherlock.com, and it extends from MapActivity, so it should work.
The error I am getting is the following:
FATAL EXCEPTION: main
E/AndroidRuntime(954): android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.maps.MapView
E/AndroidRuntime(954): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
E/AndroidRuntime(954): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
Does anyone know what is going on?
source
share