<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="example.duanyuz8_7lx.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.TabLayout android:id="@+id/tab" android:layout_width="match_parent" android:layout_height="50dp"/> <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="match_parent"/> </LinearLayout> <fragment class="example.duanyuz8_7lx.BlankFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="start"/> </android.support.v4.widget.DrawerLayout>
private void inimActionBar() { ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); mToggme = new ActionBarDrawerToggle(MainActivity.this, mDrawerLayout, R.string.open, R.string.close); mToggme.syncState(); mDrawerLayout.addDrawerListener(mToggme); } @Override public boolean onOptionsItemSelected(MenuItem item) { if (mToggme.onOptionsItemSelected(item)) { return true; } return super.onOptionsItemSelected(item); }