我有这段代码
private void setupDrawerLayout() {
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
final int itemId = menuItem.getItemId();
switch (itemId) {
case R.id.drawer_my_mixes:
replaceFragment(MyMixesFragment.newInstance());
drawerLayout.closeDrawers();
break;
and so on...
我想要通过点击R.id.drawer_settings
来制作浓缩咖啡,这将基本上打开一个名为SettingsFragment的片段。我该怎么做?我尝试过但没有成功。
private ViewInteraction navigateToSettings(){
openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());
return onView(withText("Settings")).perform(click());
}
onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
。更多信息请查看 这个答案。 - MiguelHincapieC