I am new in google map for android. I just tried simple google map in Fragment and i got stop working. Maybe this Question same with this but i have not found good answer. I hope someone can help me. This java code
public class MenujuStasiun extends Fragment {
public MenujuStasiun() {
}
private GoogleMap googleMap;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.mstasiun, container, false);
try {
// Loading map
initilizeMap();
} catch (Exception e) {
e.printStackTrace();
}
return rootView;
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap();
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getActivity(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
@Override
public void onResume() {
super.onResume();
initilizeMap();
}
}
this mstasiun.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
class="com.google.android.gms.maps.MapFragment"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
this is the logcat error
12-27 23:36:28.336: E/AndroidRuntime(1310): android.view.InflateException: Binary XML file line #6: Error inflating class fragment
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-27 23:36:28.336: E/AndroidRuntime(1310): at com.tugasbesar.medantrain.MenujuStasiun.onCreateView(MenujuStasiun.java:21)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.app.Fragment.performCreateView(Fragment.java:1700)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.app.Activity.onCreateView(Activity.java:4777)
12-27 23:36:28.336: E/AndroidRuntime(1310): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)