首先要定义好要切换的容器布局文件(就是在哪个布局文件里进行切换)
activity_frame.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" >
<android.support.v4.widget.DrawerLayout
android:id="@+id/layout_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#F0F0F7" >
<!-- 主界面 -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!-- 内容部分 -->
<RelativeLayout
android:id="@+id/layout_bodys"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</RelativeLayout>
<!-- 标题栏 -->
<LinearLayout
android:id="@+id/layout_title"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#C0C0C7"
android:orientation="horizontal"
android:padding="10dp" >
<Button
android:id="@+id/btn"
android:layout_width="27dp"
android:layout_height="16dp"
android:background="@drawable/menu" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:paddingRight="27dp"
android:text="@string/title"
android:textColor="#