Rajat Dembla Rajat Dembla - 5 months ago 58
Android Question

Open new Activity after click item in navigation drawer menu

Hello Everyone I am a beginner and just started coding in android i found a tutorial regarding, how to make navigation drawer.

Tutorial Link:- http://www.android4devs.com/2015/06/navigation-view-material-design-support.html

I do wanna know is there any way if i click on options in navigation drawer, a new activity will open it will be a great help for answer.

Thank you in advance

Answer
mDrawerList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
                int position, long id) {
switch (position) {
case 1:
Intent intent= new Intent(CurrentActivity.this,AnotherActivity.class);
startActivity(intent);
break;
case 2:
...
default:
    break;
    }
}
});
Comments