按照说明实现 Java 代码后,当我选择导航抽屉上的课程项目时,它仍然显示与注释项目相同的内容。请帮忙
mNoteLayoutManager = new LinearLayoutManager(this);
mCoursesLayoutManager = new GridLayoutManager(this, 2);
List<NoteInfo> notes = DataManager.getInstance().getNotes();
mNoteRecyclerAdapter = new NoteRecyclerAdapter(this, notes);
List<CourseInfo> courses = DataManager.getInstance().getCourses();
mCourseRecyclerAdapter = new CourseRecyclerAdapter(this, courses);
displayNotes();
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_notes) {
displayNotes();
} else if (id == R.id.nav_courses) {
displayCourses();
} else if (id == R.id.nav_share) {
handleSelection("Don't you think you've shared enough");
} else if (id == R.id.nav_send) {
handleSelection("Send");
}
DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this, NoteActivity.class));
}
});
千万里不及你
相关分类