I followed this StackOverflow post's instructions and managed to get the ActionBarDrawerToggle and its animation working. However, no navigation drawer slides out. Why is that?
activity_main.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity"
tools:ignore="MergeRootFrame"
android:fitsSystemWindows="true" >
<include layout="@layout/toolbar" />
<it.neokree.materialtabs.MaterialTabHost
android:id="@+id/materialTabHost"
android:layout_width="match_parent"
android:layout_height="48dp"
app:textColor="#FFFFFF"
app:primaryColor="#33B5E5"
app:accentColor="#FFFFFF" />
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Main layout -->
<FrameLayout
android:id="@+id/main_fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- Nav drawer -->
<fragment
android:id="@+id/nav_drawer"
android:name="com.wsandhu.conjugation.DrawerFragment"
android:layout_width="@dimen/drawer_width"
android:layout_height="match_parent"
android:layout_gravity="left|start" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
Here's the code in the onCreate() method in MainActivity.java:
ActionBarDrawerToggle mDrawerToggle;
DrawerLayout mDrawerLayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.app_name, R.string.app_name);
mDrawerLayout.setDrawerListener(mDrawerToggle);
...
if (savedInstanceState == null) {
new Handler().post(new Runnable() {
@Override
public void run() {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new MainFragment())
.commit();
}
});
}
...
}
I have a DrawerFragment class and its XML file, but as I said, nothing slides out when I tap the ActionBarDrawerToggle in my app. The toggle animates perfectly.
The five methods that needed to be overrided as stated in the other post are in my MainActivity, after the onCreate() method. I really don't know what else to add, I can't figure this out.
Thanks in advance.