在logcat的錯誤:E/FragmentManager(7158): No view found for id 0x7f05000d (com.mybiz.mygame:id/fragment_container) for fragment MainMenuFragment{4052d780 #0 id=0x7f05000d}
Android的碎片錯誤:沒有查看發現ID
確定這裏是如何應用程序設置:
兩個瓦爾創建:
private static View oGoogleGamesView ;
private static RelativeLayout oViewGroup ;
然後在的onCreate:
oViewGroup = new RelativeLayout (this) ;
setContentView (oViewGroup) ;
LayoutInflater inflater = (LayoutInflater)this.getSystemService (Context.LAYOUT_INFLATER_SERVICE) ;
oGoogleGamesView = inflater.inflate (R.layout.ggmain, oViewGroup, false) ;
然後我試圖說明的片段:
// create fragments
mMainMenuFragment = new MainMenuFragment();
// listen to fragment events
mMainMenuFragment.setListener(this);
// add initial fragment (welcome fragment)
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container,
mMainMenuFragment).commit();
在這裏,它崩潰的錯誤在上面。下面是XML文件:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
我能做些什麼來顯示片段沒有崩潰?
感謝您e回覆,但是這樣做會破壞我的應用程序,我需要將我的ContentView設置爲oViewGroup。 – Selzier
可以請你發佈MainMenuFragment的代碼 – 2013-10-18 05:36:48