Reputation: 231
So I have been following Slidnerd tutorial on the Navigation Drawer. The problem arises when I'm trying to create an instance of ActionBarDrawerToggle to specify the Activity
, the DrawerLayout
and the Toolbar
.
(NavigationDrawerFragment)getSupportFragmentManager().findFragmentById(R.id.fragment_nav_drawer);
drawerFragment.setUp((DrawerLayout) findViewById (R.id.drawer_layout, toolbar);
I'm getting an error underlying the (R.id.drawer_layout, toolbar). The error says:" findViewById (int) in Activity cannot be applied to (int, android.support.v7.widget.Toolbar".
I tried a suggested solution which was to import android.support.v4.app.Fragment but even after trying this the problem still persists, I even tried the vice versa. I'm also willing to post my relevant code if requested.
Does anyone know how to fix this?
All help is appreciated. Thanks and have a good day!
Upvotes: 4
Views: 1511
Reputation: 299
just replace your line with this and the error is gone....
drawerFragment.setUp((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);
Upvotes: 3
Reputation: 2749
This error is because findViewById
only takes an int, and not an int and a Toolbar
. It should be used like this:
drawerFragment.setup((DrawerLayout)findViewById(R.id.drawer_layout), toolbar);
Upvotes: 3