1

由于 nv = (NavigationView) findViewById(R.id.nav) 上的 switch 语句而无法访问语句

     nv = (NavigationView) findViewById(R.id.nav);

    nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {
            switch (item.getItemId()) {
                case R.id.menu_posts:
                    Intent iMenuPosts = new Intent(getApplicationContext(), PostsActivity.class);
                    startActivity(iMenuPosts);
                    break;

它说这部分代码无法访问

case R.id.menu_don:
                    Intent imMenuDon = new Intent(getApplicationContext(), DonActivity.class);
                    startActivity(imMenuDon);
            }
            return true;
        }
    });
}

}
4

0 回答 0