如何从片段注销到活动

时间:2015-11-14 07:05:54

标签: login logout drawerlayout

我正在尝试从我正在开发的应用程序注销。我的应用程序在抽屉布局中,每次我调用片段时都从抽屉中出来。但这次我想调用另一个包中的活动。最后面对一个错误..不幸停了下来。该怎么办 !!!有人可以建议我!!!

这是代码..

private void selectItemFragment(int position){

    Fragment fragment = null;
    FragmentManager fragmentManager = getSupportFragmentManager();
    switch(position) {
        default:
        case 0:
            fragment = new ProfileFragment();
            Toast.makeText(getApplicationContext(),"Profile Fragment 1"+position,Toast.LENGTH_LONG).show();
            break;
        case 1:
            fragment = new UploadQuestionFragment();
            Toast.makeText(getApplicationContext(),"Fragment 2 "+position,Toast.LENGTH_LONG).show();
            break;
        case 2:
            fragment = new DefaultFragment();
            Toast.makeText(getApplicationContext(),"Fragment 3"+position,Toast.LENGTH_LONG).show();
            break;
        case 3:
            fragment = new DefaultFragment();
            Toast.makeText(getApplicationContext(),"Fragment 4 "+position,Toast.LENGTH_LONG).show();
            break;
        case 4:
            fragment = new DefaultFragment();
            Toast.makeText(getApplicationContext(),"Fragment 5 "+position,Toast.LENGTH_LONG).show();
        break;
        case 5:
            //fragment = new LogOutFragment();
            Intent intent = new Intent(MainActivity.this, FirstActivity.class);
            startActivity(intent);
            break;

    }
    fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment).commit();

    mDrawerList.setItemChecked(position, true);
    setTitle(titles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

0 个答案:

没有答案