I am getting a DrawerLayout and ActionBarDrawerToggle cannot be resolved to a type
compile error.I am added an import to my project.But I am getting an error again
You cannot have more than two direct children in your DrawerWidget
. Right now, you have three direct children in your widget. That is the reason you are getting error in you xml. I have created a sample project for custom Drawer Layout. Please check it here. I think you'll get everything you need in that project.
Looking at your layout, it looks like you need to have custom layouts in your Drawer widget. Please keep in mind that DrawerWidget
only supports two direct children. Think of it as having two xml files combined in one layout.xml file.
First child of DrawerWidget
is the main content view which will be shown as the normal screen. Think of this as the xml file that you have to show on your main screen. You can have a RelativeLayout
here and add anything in it which will be shown on main screen.
Second child of DrawerLayout
is the slider, which will slide-out when you click the button to show slider. Think of this as another xml file, which will only be shown when slider is shown. You can have RelatvieLayout
here too.
What layouts you are using in it, totally depends on what kind of view you need. But don't forget, only two direct children rule with DrawerLayout
.
Check the sample project for more information. It contains everything custom, so will help you to have a better idea.
NOTE: Also please don't forget to add android-support-v4.jar
to libs folder of you project.
Check if you have imported the DrawerLayout class properly.Check your import statement.It should be something like this.
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
did all options checked?