frogermcs / InstaMaterial

Implementation of Instagram with Material Design (originally based on Emmanuel Pacamalan's concept)
Apache License 2.0
4.98k stars 1.44k forks source link

How Can I Add some onclicklisteners over the drawer?? #13

Open hylarucoder opened 9 years ago

hylarucoder commented 9 years ago

You code well!

And i have a very simple question to ask you.

app/src/main/java/io/github/froger/instamaterial/ui/adapter/GlobalMenuAdapter.java

you set the drawer items , but how can i add a click event?

HarlonWang commented 9 years ago

you can try this : GlobalMenuView.setOnItemClickListener....

hylarucoder commented 9 years ago

Oh ,Thank You.

randhika commented 9 years ago

@BaseActivity private void setupDrawer() { DrawerMenuView menuView = new DrawerMenuView(this); menuView.setOnHeaderClickListener(this); drawerLayout = DrawerLayoutInstaller.from(this) .drawerRoot(R.layout.drawer_root) .drawerLeftView(menuView) .drawerLeftWidth(Utils.dpToPx(300)) .withNavigationIconToggler(getToolbar()) .build(); menuView.setOnItemClickListener(new DrawerItemClickListener()); } private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { int mPosition = (position - 1); selectedItem(mPosition); drawerLayout.closeDrawer(Gravity.START); } }

protected void selectedItem(int selectedItem){}

@MainActivity @Override protected void selectedItem(int selectedItem) { Toast.makeText(MainActivity.this, "Position = "+selectedItem, 1).show(); }