OSDN Git Service

fix typo in code sample
[android-x86/frameworks-base.git] / docs / html / training / implementing-navigation / nav-drawer.jd
index 756e6c4..38b7345 100644 (file)
@@ -1,4 +1,5 @@
 page.title=Creating a Navigation Drawer
+page.tags="DrawerLayout", "navigation"
 
 trainingnavtop=true
 
@@ -24,6 +25,12 @@ trainingnavtop=true
 <p class="filename">NavigationDrawer.zip</p>
 </div>
 
+<div class="download-box">
+<a href="http://developer.android.com/downloads/design/Android_Navigation_Drawer_Icon_20130516.zip"
+  class="button">Download the nav drawer icons</a>
+<p class="filename">Android_Navigation_Drawer_Icon_20130516.zip</p>
+</div>
+
 </div>
 </div>
 
@@ -117,6 +124,7 @@ android.widget.ArrayAdapter} or {@link android.widget.SimpleCursorAdapter}).</p>
 <pre>
 public class MainActivity extends Activity {
     private String[] mPlanetTitles;
+    private DrawerLayout mDrawerLayout;
     private ListView mDrawerList;
     ...
 
@@ -126,6 +134,7 @@ public class MainActivity extends Activity {
         setContentView(R.layout.activity_main);
 
         mPlanetTitles = getResources().getStringArray(R.array.planets_array);
+        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
         mDrawerList = (ListView) findViewById(R.id.left_drawer);
 
         // Set the adapter for the list view
@@ -184,9 +193,9 @@ private void selectItem(int position) {
                    .commit();
 
     // Highlight the selected item, update the title, and close the drawer
-    mDrawer.setItemChecked(position, true);
+    mDrawerList.setItemChecked(position, true);
     setTitle(mPlanetTitles[position]);
-    mDrawerLayout.closeDrawer(mDrawer);
+    mDrawerLayout.closeDrawer(mDrawerList);
 }
 
 &#64;Override
@@ -295,6 +304,8 @@ it with its constructor, which requires the following arguments:</p>
   <li>The {@link android.app.Activity} hosting the drawer.
   <li>The {@link android.support.v4.widget.DrawerLayout}.
   <li>A drawable resource to use as the drawer indicator.
+   <p><a href="http://developer.android.com/downloads/design/Android_Navigation_Drawer_Icon_20130516.zip"
+>Download the standard navigation icons</a> (available for both dark and light themes).</p>
   <li>A String resource to describe the "open drawer" action (for accessibility).
   <li>A String resource to describe the "close drawer" action (for accessibility).
 </ul>
@@ -314,8 +325,13 @@ public class MainActivity extends Activity {
         ...
 
         mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
-        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
-                R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
+        mDrawerToggle = new ActionBarDrawerToggle(
+                this,                  /* host Activity */
+                mDrawerLayout,         /* DrawerLayout object */
+                R.drawable.ic_drawer,  /* nav drawer icon to replace 'Up' caret */
+                R.string.drawer_open,  /* "open drawer" description */
+                R.string.drawer_close  /* "close drawer" description */
+                ) {
 
             /** Called when a drawer has settled in a completely closed state. */
             public void onDrawerClosed(View view) {
@@ -365,4 +381,4 @@ public class MainActivity extends Activity {
 </pre>
 
 <p>For a complete example of a navigation drawer, download the sample available at the
-<a href="#top">top of the page</a>.</p>
\ No newline at end of file
+<a href="#top">top of the page</a>.</p>