Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Drawer Layout Can't Find R.layout.drawer_list

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.

like image 786
Elliott Avatar asked Jan 27 '14 21:01

Elliott


People also ask

What is drawerlayout in Android?

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.

How to manage navigation drawer in Android?

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.

What is the use of drawer layout?

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.

How to check if the drawer view is currently open or not?

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.


1 Answers

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.

like image 151
fweigl Avatar answered Oct 15 '22 23:10

fweigl