Effect
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/064Z62L4-0.png "style =" float: none; "title =" 1.png"/>
650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/064Z64302-1.png "style =" float: none; "title =" 2.png"/>
Use the latest android-support-v4.jar, see attachment.
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- The main content view --> ... <!-- The navigation drawer --> <ListView android:id="@+id/left_drawer" android:layout_width="120dp" android:layout_height="match_parent" android:layout_gravity="start" android:choiceMode="singleChoice" android:divider="@android:color/transparent" android:dividerHeight="0dp" android:background="#EEA9B8"/> </android.support.v4.widget.DrawerLayout>
/** Drawer navigation variable */private DrawerLayout mDrawerLayout; private ListView mDrawerList; private ActionBarDrawerToggle mDrawerToggle ;... /** drawer navigation related */mDrawerLayout = (DrawerLayout) findViewById (R. id. drawer_layout); mDrawerList = (ListView) findViewById (R. id. left_drawer); mDrawerLayout. setDrawerShadow (R. drawable. draw, GravityCompat. RELATIVE_HORIZONTAL_GRAVITY_MASK); mDrawerList. setAdapter (new SimpleAdapter (This, getDrawerItems (false), R. layout. drawer_item, new String [] {"drawer_img", "drawer_title"}, new int [] {R. id. drawer_img, R. id. drawer_title}); mDrawerList. setOnItemClickListener (new DrawerItemClickListener (); mDrawerToggle = new ActionBarDrawerToggle (this,/** host Activity */mDrawerLayout,/** DrawerLayout object */R. drawable. draw,/** nav drawer image to replace 'up' caret */R. strin G. search_label,/** "open drawer" description for accessibility */R. string. defalut_text/** "close drawer" description for accessibility */) {public void onDrawerClosed (View view) {getActionBar (). setTitle ("onDrawerClosed"); invalidateOptionsMenu (); // creates call to onPrepareOptionsMenu ()} public void onDrawerOpened (View drawerView) {getActionBar (). setTitle ("onDrawerOpened"); invalidateOpti OnsMenu (); // creates call to onPrepareOptionsMenu () }}; mDrawerLayout. setDrawerListener (mDrawerToggle );... /*** listens to the drawer navigation item Click Event */private class DrawerItemClickListener implements ListView. onItemClickListener {@ Override public void onItemClick (AdapterView <?> Parent, View view, int position, long id) {selectItem (view, position) ;}} private boolean flag = false; private void selectItem (View view, int position) {if (position = 0) {if (! Flag) {mDrawerList. setAdapter (new SimpleAdapter (this, getDrawerItems (true), R. layout. drawer_item, new String [] {"drawer_img", "drawer_title"}, new int [] {R. id. drawer_img, R. id. drawer_title}); flag = true;} else {mDrawerList. setAdapter (new SimpleAdapter (this, getDrawerItems (false), R. layout. drawer_item, new String [] {"drawer_img", "drawer_title"}, new int [] {R. id. drawer_img, R. id. drawer_title}); flag = false ;}} else {TextView title = (TextView) view. findViewById (R. id. drawer_title); String cityName = title. getText (). toString (); this. cityInput. setText (cityName );}}
For more information, see my translation http://lichen.blog.51cto.com/697816/1211685.
This article from the "wIsper technology into art" blog, please be sure to keep this source http://lichen.blog.51cto.com/697816/1212912