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.
MainActivity.java:
import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.widget.DrawerLayout;
public class MainActivity extends Activity {
private DrawerLayout mDrawerLayout; --->DrawerLayout undefined
private ListView mDrawerList;
@SuppressWarnings("deprecation")
private ActionBarDrawerToggle mDrawerToggle; ---->undefined error
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
setContentView(R.layout.activity_main);
}
}
Check if you have imported the DrawerLayout class properly.Check your import statement.It should be something like this.
what about Order and Export tab
did all options checked?
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 aRelativeLayout
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 haveRelatvieLayout
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.