/** 设置登陆界面 已登陆:我的课表+我的资料 未登陆:登陆+注册 登陆状态改变时更新menudrawer的菜单显示 */
  public void setLoginedFragment(String username) {
    this.username = username;
    mloginFragment = new HomeFragment();
    if (username == null || "".equals(username)) {
      mloginFragment.addpager("登陆", new LoginFragment());
      mloginFragment.addpager("注册", new RegistFragment());
      SharedPreferences sp = getPreferences(0);
      Editor edit = sp.edit();
      edit.putBoolean("autologin", false);
      edit.commit();
      autologin = false;
      settingAdapter.setTitle0("登陆");
      settingAdapter.setTitle("登陆");
    } else {
      mloginFragment.addpager("我的课表", new MyCourseFragment());
      mloginFragment.addpager("我的资料", new MyInfoFragment());
      settingAdapter.setTitle0(username);
      settingAdapter.setTitle(username);
    }

    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container, mloginFragment);
    ft.addToBackStack(null);
    ft.commit();
    //		settingAdapter.notifyDataSetChanged();//无法及时改变状态,不知道为什么 - -
    //		settingAdapter.notifyDataSetInvalidated();
  }
 /** 主界面初始化 */
 public void initContentview() {
   // actionbar
   ActionBar supportActionBar = getSupportActionBar();
   supportActionBar.setIcon(R.drawable.ic_duobei);
   supportActionBar.setTitle("多贝公开课");
   // menudrawer
   mDrawer = MenuDrawer.attach(this, Type.OVERLAY);
   mDrawer.setContentView(R.layout.activity_main);
   // 初始化3个tab
   fm = getSupportFragmentManager();
   FragmentTransaction ft = fm.beginTransaction();
   mhomeFragment = new HomeFragment();
   mhomeFragment.addpager("新课速递", new NewCourseFragment());
   mhomeFragment.addpager("每日推荐", new DailyRecFragment());
   mhomeFragment.addpager("精选课程", new PickCourseFragment());
   ft.add(R.id.container, mhomeFragment);
   ft.addToBackStack(null);
   ft.commit();
 }
  /** 点击切换fragment */
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Fragment fragment = null;
    switch (position) {
      case MENU_LOGIN:
        if (username != null && !"".equals(username)) {
          if (mloginFragment != null) {
            fragment = mloginFragment;
            break;
          }
          mloginFragment = new HomeFragment();
          mloginFragment.addpager("我的课表", new MyCourseFragment());
          mloginFragment.addpager("我的资料", new MyInfoFragment());
          fragment = mloginFragment;
        } else {
          if (mloginFragment != null) {
            fragment = mloginFragment;
            break;
          }
          mloginFragment = new HomeFragment();
          mloginFragment.addpager("登陆", new LoginFragment());
          mloginFragment.addpager("注册", new RegistFragment());
          fragment = mloginFragment;
        }
        break;
      case MENU_HOME:
        if (mhomeFragment != null) {
          fragment = mhomeFragment;
          break;
        }
        mhomeFragment = new HomeFragment();
        mhomeFragment.addpager("新课速递", new NewCourseFragment());
        mhomeFragment.addpager("每日推荐", new DailyRecFragment());
        mhomeFragment.addpager("精选课程", new PickCourseFragment());
        fragment = mhomeFragment;

        break;
      case MENU_GROUP:
        if (mgroupFragment != null) {
          fragment = mgroupFragment;
          break;
        }
        mgroupFragment = new HomeFragment();
        mgroupFragment.addpager("热门话题", new TopicHotFragment());
        mgroupFragment.addpager("发现小组", new GroupFindFragment());
        fragment = mgroupFragment;
        break;
      case MENU_COURSE:
        if (mCourseListFragment != null) {
          fragment = mCourseListFragment;
          break;
        }
        mCourseListFragment = new PublicCourseListFragment();
        fragment = mCourseListFragment;
        break;
      case MENU_SETTING:
        startActivity(new Intent(this, SettingActivity.class));
        break;
      default:
        break;
    }
    if (fragment != null) {
      FragmentTransaction ft = fm.beginTransaction();
      ft.replace(R.id.container, fragment);
      ft.addToBackStack(null);
      ft.commit();
    }
    mDrawer.closeMenu(true);
  }