我收到了以下错误:
找不到符号变量片段
如何解决此错误?
public boolean onNavigationItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.toi) {
fragment= new FragmentOne();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.content_frame, fragment);
ft.commit();
return true;
} else if ( id ==R.id.thehindu){
}else if (id == R.id.support) {
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
答案 0 :(得分:1)
变化:
fragment= new FragmentOne();
要:
Fragment fragment= new FragmentOne();