本文介绍了单击导航抽屉菜单中的项目后,打开新的活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我是一个初学者,刚开始在android中编码,我找到了一个有关如何制作导航抽屉的教程.
教程链接:- http://www. android4devs.com/2015/06/navigation-view-material-design-support.html
我想知道如果我单击导航抽屉中的选项,有什么办法,一个新的活动将打开,这将为答案提供很大的帮助.
提前谢谢
解决方案
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;
}
}
});
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
解决方案
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;
}
}
});
这篇关于单击导航抽屉菜单中的项目后,打开新的活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!