実行時に Google マップを特定のレイアウトに追加しようとしています。
mMapFragment = SupportMapFragment.newInstance();
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(android.R.id.content, mMapFragment, MAP_FRAGMENT_TAG);
mainLayout.addView(mMapFragment);
mainLayout.addView(mMapFragment)の追加時にnull ポインター エラーが表示されます。
エラー
(19:34) amitsharma.cssoft: 09-30 19:23:40.457: E/AndroidRuntime(16595): FATAL EXCEPTION: main
09-30 19:23:40.457: E/AndroidRuntime(16595): java.lang.NullPointerException
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.view.ViewGroup.addView(ViewGroup.java:1821)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.view.ViewGroup.addView(ViewGroup.java:1808)
09-30 19:23:40.457: E/AndroidRuntime(16595): at com.example.project_katchup.Settings.ShowCurrentLocation(Settings.java:222)
09-30 19:23:40.457: E/AndroidRuntime(16595): at com.example.project_katchup.Settings.access$0(Settings.java:211)
09-30 19:23:40.457: E/AndroidRuntime(16595): at com.example.project_katchup.Settings$1.onClick(Settings.java:151)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.view.View.performClick(View.java:2538)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.view.View$PerformClick.run(View.java:9152)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.os.Handler.handleCallback(Handler.java:587)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.os.Handler.dispatchMessage(Handler.java:92)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.os.Looper.loop(Looper.java:130)
09-30 19:23:40.457: E/AndroidRuntime(16595): at android.app.ActivityThread.main(ActivityThread.java:3687)
09-30 19:23:40.457: E/AndroidRuntime(16595): at java.lang.reflect.Method.invokeNative(Native Method)
09-30 19:23:40.457: E/AndroidRuntime(16595): at java.lang.reflect.Method.invoke(Method.java:507)
09-30 19:23:40.457: E/AndroidRuntime(16595): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
09-30 19:23:40.457: E/AndroidRuntime(16595): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
09-30 19:23:40.457: E/AndroidRuntime(16595): at dalvik.system.NativeStart.main(Native Method)
09-30 19:28:46.757: I/Process(16595): Sending signal. PID: 16595 SIG: 9