public class MainActivity extends Activity { private DrawerLayout mDrawerLayout; private RelativeLayout mDrawerList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initDrawer(); } private void initDrawer() { mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (RelativeLayout) findViewById(R.id.left_drawer); findViewById(R.id.ImageIcon).setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (mDrawerLayout.isDrawerOpen(mDrawerList)) { mDrawerLayout.closeDrawer(mDrawerList); } else { mDrawerLayout.openDrawer(mDrawerList); } } }); } }
2014年12月11日 星期四
Android-筆記 Navigation Drawer
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言