You should use a FrameLayout for that, that way you don't have to specify the fragment class in the XML and that way it is not limited to one class.
<FrameLayout
android:id="@+id/contentFragment"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
and than you can set the fragment in the code like this
Fragment fragment = new YourFragment();
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.replace(R.id.contentFragment, fragment);
transaction.commit();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…