I am about two weeks in to Android development, and I'm sure there is a very simple answer to this, but will be needing to create a drawer slider for my application. Unfortunately, I cannot seem to find R.layout.drawer_list for my adapter set-up. I currently have a listView, but want this to be in a sliding drawer. I follow the api guides on developer.android and can't seem to get past this:
mDrawerList.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_list_item, mPlanetTitles));
Now this is just pasted from developer.android but what it all comes down to is that eclipse can't find R.layout.drawer_list_item. I get no list of options from R.layout, but do receive a list from android.R.layout... unfortunately, that list doesn't contain the drawer_list_item option.
Any help would be greatly appreciated.
In Android, DrawerLayout acts as top level container for window content that allows for interactive “drawer” views to be pulled out from one or both vertical edges of the window.
The NavigationView is the “real” menu of our app. The menu items are written in nav_items file. Let’s we discuss some important methods of Navigation Drawer that may be called in order to manage the Navigation Drawer. 1. closeDrawer (int gravity): This method is used to close the drawer view by animating it into view.
Drawer Layout is the root layout in which we define a FrameLayout and a Navigation View. In Navigation View we set the items from menu file and FrameLayout is used to replace the Fragments on the click of menu items.
3. isDrawerOpen (int drawerGravity): This method is used to check the drawer view is currently open or not. It returns true if the drawer view is open otherwise it returns false.
You'll have to create the R.layout.drawer_list_item
layout yourself (it need only be a simple layout with a TextView; the layout is the one that represents one item in your drawer list). Have you downloaded the sample app? You can copy&paste most stuff, get it working and then go from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With