logcat中的错误:E/FragmentManager(7158): No view found for id 0x7f05000d (com.mybiz.mygame:id/fragment_container) for fragment MainMenuFragment{4052d780 #0 id=0x7f05000d}
好的,这是应用程序的设置方式:
创建了两个变量:
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>
如何在不崩溃的情况下显示片段?