我收到一个错误“无法找到符号变量片段”

时间:2016-07-04 18:23:50

标签: android

我收到了以下错误:

  

找不到符号变量片段

如何解决此错误?

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;
}

1 个答案:

答案 0 :(得分:1)

变化:

fragment= new FragmentOne();

要:

Fragment fragment= new FragmentOne();