Leonz
Leonz

Reputation: 307

Making Android Toolbar

I downloaded Google's Navigation Drawer sample app and the app uses android.support.v4.app.ActionBarDrawerToggle. v4 was deprecated and I tried using android.support.v7.app.ActionBarDrawerToggle, but ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close ) reports error at R.drawable.ic_drawer saying that it should be a Toolbar object. Can anyone here explain or point to some Toolbar creation tutorial, since Google doesn't have any of their own?

Upvotes: 0

Views: 47

Answers (1)

Mike M.
Mike M.

Reputation: 39191

The v7 version of ActionBarDrawerToggle has two constructors; one that takes a Toolbar, and one that does not. In your case, you can simply omit the third argument in your posted constructor call, and the ActionBarDrawerToggle will find what it needs itself.

Additionally, if you're following an old example, you might also receive a deprecation warning for the DrawerLayout#setDrawerListener() method. With the newest version, you should now use the addDrawerListener() method.

And lastly, you might want to update the example to use AppCompatActivity as well. I'm pretty sure the v7 version of ActionBarDrawerToggle works just fine with a regular Activity and ActionBar, but if something doesn't seem right, it might be the version difference.

Upvotes: 1

Related Questions