private void selectItem(int position) {
   mCurrentSelectedPosition = position;
   if (mDrawerListView != null) {
     mDrawerListView.setItemChecked(position, true);
   }
   if (mDrawerLayout != null) {
     mDrawerLayout.closeDrawer(mFragmentContainerView);
   }
   if (mCallbacks != null) {
     if (mCurrentSelectedPosition == 0) {
       // mCallbacks.onNavigationDrawerItemSelected(getString(R.string.app_name));
       if (!AccountTemp.getUsername(getActivity()).toString().equals("")
           && !AccountTemp.getPwd(getActivity()).toString().equals("")) {
         if (getNetworkIsAvailable()) {
           Intent intent = new Intent(getActivity(), AccountSelf.class);
           intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
           startActivity(intent);
           getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_in);
         } else {
           Toast.makeText(getActivity(), "亲~断网了哦~", Toast.LENGTH_LONG).show();
         }
       } else {
         Intent intent = new Intent(getActivity(), Login.class);
         intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
         startActivity(intent);
         getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_in);
       }
       return;
     }
     mCallbacks.onNavigationDrawerItemSelected(mData.get(position - 1).getTitle());
   }
 }
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    if (mDrawerToggle.onOptionsItemSelected(item)) {
      return true;
    }

    if (item.getItemId() == R.id.scan_qrcode) {
      if (AccountTemp.getUsername(getActivity()).toString().length() == 0) {
        Toast.makeText(getActivity(), "亲~要先登录才能签到哦~", Toast.LENGTH_LONG).show();
      } else {
        Intent intent = new Intent(getActivity(), MipcaActivityCapture.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivityForResult(intent, SCANNIN_GREQUEST_CODE);
        getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_in);
      }
      return true;
    }

    return super.onOptionsItemSelected(item);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mDrawerListView =
        (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
    if (!AccountTemp.getUsername(getActivity()).toString().equals("")
        && !AccountTemp.getPwd(getActivity()).toString().equals("")) {
      headerView = inflater.inflate(R.layout.list_header_login, null);
      TextView username = (TextView) headerView.findViewById(R.id.item_title_login);
      ImageView avatar = (ImageView) headerView.findViewById(R.id.item_icon_login);

      username.setText(AccountTemp.getRealname(getActivity()));

      HttpConnSoap hs = new HttpConnSoap();
      String str = hs.GetWebServreForJson("GetAccount");
      JSONArray jsonArray;
      try {
        jsonArray = new JSONObject(str).getJSONArray("Table");
        int count = jsonArray.length();
        for (int index = 0; index < count; index++) {
          if (jsonArray
              .optJSONObject(index)
              .getString("Username")
              .toString()
              .equals(AccountTemp.getUsername(getActivity()).toString())) {
            try {
              URL url =
                  new URL(
                      Url.imageUrl + jsonArray.optJSONObject(index).getString("Avatar").toString());
              avatar.setImageBitmap(BitmapFactory.decodeStream(url.openStream()));

            } catch (Exception e) {

            }
            break;
          } else {
            continue;
          }
        }
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

      avatar.setBackgroundResource(R.drawable.avatar);

    } else {
      headerView = inflater.inflate(R.layout.list_header, null);
    }

    Log.e(
        "666666666666666666666",
        AccountTemp.getUsername(getActivity()).toString()
            + "+"
            + AccountTemp.getPwd(getActivity()).toString());

    mDrawerListView.addHeaderView(headerView);
    mDrawerListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
          }
        });
    String[] itemTitle = getResources().getStringArray(R.array.item_title);
    int[] itemIconRes = {
      R.drawable.ic_drawer_home, R.drawable.ic_drawer_history, R.drawable.ic_drawer_setting
    };

    for (int i = 0; i < itemTitle.length; i++) {
      DrawerListItem item =
          new DrawerListItem(getResources().getDrawable(itemIconRes[i]), itemTitle[i]);
      mData.add(item);
    }
    selectItem(mCurrentSelectedPosition);
    DrawerListAdapter adapter = new DrawerListAdapter(this.getActivity(), mData);
    mDrawerListView.setAdapter(adapter);
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
    return mDrawerListView;
  }