最初に、私はここで気をつけました: Activity から FragmentActivity を開始すると、次の問題が発生しました:
マップ アクティビティ:
public class MapsActivity extends FragmentActivity {
private GoogleMap mMap;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maps);
setUpMapIfNeeded();
}
...
MainActivityから次のように開始します。
startActivity(new Intent(this, MapsActivity.class));
アクティビティは Android マニフェストに登録されます。
<activity android:name="de.xbjoernx.gapp.MapsActivity"></activity>
エラー
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{de.xbjoernx.gapp/de.xbjoernx.gapp.MapsActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
at android.app.ActivityThread.access$600(ActivityThread.java:153)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5227)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:323)
at android.app.Activity.setContentView(Activity.java:1881)
at de.xbjoernx.gapp.MapsActivity.onCreate(MapsActivity.java:19)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2262)
... 11 more
Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
... 20 more
それを修正する方法はありますか?
これまでありがとう:)