我希望导航菜单中的项目在我将提供的活动中打开。
例如;
iDrawerItems.add(new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_home_black_24dp));
我希望它在MainActivity.java中打开
iDrawerItems.add(new PrimaryDrawerItem().withName("Speech-to-Text").withIcon(R.drawable.ic_mic));
我希望它在按下时在Main3Ativity.java中打开
请帮助我修复代码,谢谢
我尝试过,但是没有用
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withName("Speech-to-Text").withIcon(R.drawable.ic_mic);
item1.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Intent intent = new Intent(getApplicationContext(), Main3Activity.class);
getApplicationContext().startActivity(intent);
return false;
}
});
// Navigation menu items
List<IDrawerItem> iDrawerItems = new ArrayList<>();
iDrawerItems.add(new PrimaryDrawerItem().withName("Home").withIcon(R.drawable.ic_home_black_24dp));
iDrawerItems.add(new PrimaryDrawerItem().withName("Notes").withIcon(R.drawable.ic_note_black_24dp));
iDrawerItems.add(new PrimaryDrawerItem().withName("Speech-to-Text").withIcon(R.drawable.ic_mic));
PrimaryDrawerItem item1 = new PrimaryDrawerItem().withName("Speech-to-Text").withIcon(R.drawable.ic_mic);
item1.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override
public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
Intent intent = new Intent(getApplicationContext(), Main3Activity.class);
getApplicationContext().startActivity(intent);
return false;
}
});