进行切换的两个Java代码都是activity,不知道怎么改为fagment
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Activity activity = null;
switch (item.getItemId()){
case R.id.nav_cat:
activity = new MainActivity();
break;
case R.id.nav_dog:
activity = new notepad();
break;
}
getSupportFragmentManager().beginTransaction().replace(R.id.main_container,activity).commit();
错误显示