1

I am really new to Android Studio. I can't figure out how to make ActionBarDrawerToggle take the navigation drawer image that I am trying to pass it. It gives me the error that it was expecting a Toolbar instead of an Int (my image). Please see a picture (Toolbar error link) of the error I am getting below.

I understand from: http://developer.android.com/training/implementing-navigation/nav-drawer.html that the ActionBarDrawerToggle should be able to take my drawable resource file which I downloaded from the above link. I have no idea how to fix this. Any help is greatly appreciated!

This is my error image: Toolbar error

EDIT: so i got help from this link: ActionBarDrawerToggle No Suitable Constructor Drawable The answer said to remove the drawable file since this is android.support.v7.app.ActionBarDrawerToggle; So I did but other people are complaining that this makes an up action and doesn't show the drawer icon. So I found this: https://stackoverflow.com/a/22612901/5482380 But not sure if this is good solution???????????

Community
  • 1
  • 1
aahmed31
  • 39
  • 1
  • 7
  • It appears that the class they reference in this example from the `v4` support library is now [deprecated](http://developer.android.com/reference/android/support/v4/app/ActionBarDrawerToggle.html). Unfortunately, the [recommended `v7` version](http://developer.android.com/reference/android/support/v7/app/ActionBarDrawerToggle.html) doesn't use a constructor that accepts a drawable resource id. – PPartisan Nov 01 '15 at 23:35
  • Thank you for your reply! Please see me edits. I haven't tested what happens yet since I am working on an integrated project. I am building my own project to test what happens when I do this. But other people are complaining about some up action that appears when using v7. – aahmed31 Nov 01 '15 at 23:41

1 Answers1

0

The example referenced in that tutorial is from the now deprecated v4 support library. The recommended version is now in the v7 library. The constructor for the v7 version however does not take the id of a drawable, but instead a Toolbar (as shown in your error message).

I would suggest you try the setDrawerIndicatorEnabled() and setHomeAsUpIndicator() methods. The latter takes either a drawable or an id as its argument (link).

Edit: There is also the setNavigationIcon() method on your Toolbar

PPartisan
  • 8,173
  • 4
  • 29
  • 48
  • Thank you so much for your fast response! I am new to android studio so I don't understand all the things I need to fix/add to this now. I am looking for a good tutorial on this if you know of any? Thank you so much! – aahmed31 Nov 02 '15 at 00:27
  • I found this tutorial: http://devsonline.in/content/index/category/android/topic/navigation_drawer_-_fragment_indroduction – aahmed31 Nov 02 '15 at 01:21
  • @aahmed31 I don't have any tutorial recommendations unfortunately! Are you using `Toolbar` in your app? I'd recommend you try that ( [this](http://www.android4devs.com/2014/12/how-to-make-material-design-app.html) tutorial looks like it covers it, though we're on v23 of the support library now) and then use the `setNavigationIcon()` method above on your `Toolbar`. – PPartisan Nov 02 '15 at 09:38