我有以下代码:
public class Tab_Map extends SupportMapFragment {
View view;
SupportMapFragment gmap;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
view = inflater.inflate(R.layout.tab_map, container, false);
map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.fragment1))
.getMap();
return view;
}
当我运行我的应用程序并尝试加载地图选项卡时,我收到以下错误:
E/AndroidRuntime(22627): FATAL EXCEPTION: main
E/AndroidRuntime(22627): java.lang.NullPointerException
E/AndroidRuntime(22627): at maps.ah.bg.b(Unknown Source)
E/AndroidRuntime(22627): at bgl.onTransact(SourceFile:115)
E/AndroidRuntime(22627): at android.os.Binder.transact(Binder.java:310)
E/AndroidRuntime(22627): at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onResume(Unknown Source)
E/AndroidRuntime(22627): at com.google.android.gms.maps.SupportMapFragment$a.onResume(Unknown Source)
E/AndroidRuntime(22627): at com.google.android.gms.internal.bb$6.b(Unknown Source)
E/AndroidRuntime(22627): at com.google.android.gms.internal.bb.a(Unknown Source)
E/AndroidRuntime(22627): at com.google.android.gms.internal.bb.onResume(Unknown Source)
E/AndroidRuntime(22627): at com.google.android.gms.maps.SupportMapFragment.onResume(Unknown Source)
E/AndroidRuntime(22627): at android.support.v4.app.Fragment.performResume(Fragment.java:1503)
E/AndroidRuntime(22627): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
E/AndroidRuntime(22627): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
E/AndroidRuntime(22627): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
E/AndroidRuntime(22627): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
E/AndroidRuntime(22627): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
E/AndroidRuntime(22627): at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime(22627): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(22627): at android.os.Looper.loop(Looper.java:158)
E/AndroidRuntime(22627): at android.app.ActivityThread.main(ActivityThread.java:5777)
E/AndroidRuntime(22627): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(22627): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(22627): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
E/AndroidRuntime(22627): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
E/AndroidRuntime(22627): at dalvik.system.NativeStart.main(Native Method)
我找不到这个问题的解决方案,我要做的就是在子片段中放置一张地图。
有人可以帮忙吗。