コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void finish() {
    if (mDialog != null) {
      mDialog.dismiss();
    }

    mCallback.onDestroyActionMode(this);

    mDialog = null;
    mMenu = null;
    mMenuItemArrayAdapter = null;
    mTitle = null;
  }
コード例 #2
0
  void startInternal() {
    mMenu = new SimpleMenu(mActivity);
    mCallback.onCreateActionMode(this, mMenu);
    mCallback.onPrepareActionMode(this, mMenu);
    mMenuItemArrayAdapter =
        new ArrayAdapter<MenuItem>(
            mActivity, android.R.layout.simple_list_item_1, android.R.id.text1);
    invalidate();

    // DialogFragment.show() will take care of adding the fragment
    // in a transaction. We also want to remove any currently showing
    // dialog, so make our own transaction and take care of that here.
    FragmentManager fm = mActivity.getSupportFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag("action_mode_context_menu");
    if (prev != null) {
      ft.remove(prev);
    }
    ft.addToBackStack(null);

    mDialog = new ContextMenuDialog();
    mDialog.mActionModeBase = this;
    mDialog.show(ft, "action_mode_context_menu");
  }