2014-01-14 214 views
0

不會在這裏工作是片段類調用其中包含標籤片段標籤的片段

public class FragmentAbout extends Fragment { 

    public FragmentAbout(){} 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 

     View rootView = inflater.inflate(R.layout.fragment_about, container, false); 

     return rootView; 
    } 
} 

這裏是XML文件,其中包含標籤的XML

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".FragmentTripPlan" > 


    <fragment 
     android:id="@+id/map" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/btn_draw" 
     android:layout_alignParentLeft="true" 
     class="com.google.android.gms.maps.SupportMapFragment" /> 

</RelativeLayout> 

這裏是日誌跟蹤

01-14 16:32:36.530: E/AndroidRuntime(28486): FATAL EXCEPTION: main 
01-14 16:32:36.530: E/AndroidRuntime(28486): android.view.InflateException: Binary XML file line #11: Error inflating class fragment 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:710) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.view.LayoutInflater.rInflate(LayoutInflater.java:752) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.view.LayoutInflater.inflate(LayoutInflater.java:495) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at com.c4a.itravellipaph.FragmentAbout.onCreateView(FragmentAbout.java:19) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.Fragment.performCreateView(Fragment.java:1695) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1075) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.BackStackRecord.run(BackStackRecord.java:682) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1455) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:441) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.os.Handler.handleCallback(Handler.java:725) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.os.Handler.dispatchMessage(Handler.java:92) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.os.Looper.loop(Looper.java:137) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.ActivityThread.main(ActivityThread.java:5279) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at java.lang.reflect.Method.invokeNative(Native Method) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at java.lang.reflect.Method.invoke(Method.java:511) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at dalvik.system.NativeStart.main(Native Method) 
01-14 16:32:36.530: E/AndroidRuntime(28486): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.Fragment.instantiate(Fragment.java:585) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.Fragment.instantiate(Fragment.java:560) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.app.Activity.onCreateView(Activity.java:4864) 
01-14 16:32:36.530: E/AndroidRuntime(28486): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:686) 
01-14 16:32:36.530: E/AndroidRuntime(28486): ... 19 more 

我該如何解決這個問題? 非常感謝提前!在XML 片段標籤的片段類

+0

我們展示import語句和活動代碼片段 – Raghunandan

+0

你想要一個片段內的地圖? – Raghunandan

+0

@Raghunandan是的先生。我試圖將我的FragmentActivity類代碼轉換爲片段類 – AndroidNewbie

回答