@Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int menuId = item.getItemId();
   if ((menuId == SORT_ORDER_ALPHA) || (menuId == SORT_ORDER_SIZE)) {
     mSortOrder = menuId;
     if (mCurTab != null && mCurTab.mApplications != null) {
       mCurTab.mApplications.rebuild(mSortOrder);
     }
   } else if (menuId == SHOW_RUNNING_SERVICES) {
     mShowBackground = false;
     if (mCurTab != null && mCurTab.mRunningProcessesView != null) {
       mCurTab.mRunningProcessesView.mAdapter.setShowBackground(false);
     }
   } else if (menuId == SHOW_BACKGROUND_PROCESSES) {
     mShowBackground = true;
     if (mCurTab != null && mCurTab.mRunningProcessesView != null) {
       mCurTab.mRunningProcessesView.mAdapter.setShowBackground(true);
     }
   } else if (menuId == RESET_APP_PREFERENCES) {
     buildResetDialog();
   } else {
     // Handle the home button
     return false;
   }
   updateOptionsMenu();
   return true;
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    container.setLayoutDirection(container.getResources().getConfiguration().getLayoutDirection());
    // initialize the inflater
    mInflater = inflater;

    View rootView = mInflater.inflate(R.layout.manage_applications_content, container, false);
    mContentContainer = container;
    mRootView = rootView;

    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    MyPagerAdapter adapter = new MyPagerAdapter();
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(adapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
    tabs.setTabIndicatorColorResource(android.R.color.holo_blue_light);

    // We have to do this now because PreferenceFrameLayout looks at it
    // only when the view is added.
    if (container instanceof PreferenceFrameLayout) {
      ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
    }

    if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RESET_DIALOG)) {
      buildResetDialog();
    }

    if (savedInstanceState == null) {
      // Reverse the tab list once if the language is RTL.
      if (container.isLayoutRtl()) {
        Collections.reverse(mTabs);
      }
      // First time init: make sure view pager is showing the correct tab.
      for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);
        if (tab.mListType == mDefaultListType) {
          mViewPager.setCurrentItem(i);
          break;
        }
      }
    }

    return rootView;
  }