コード例 #1
0
 @Override
 public void onListItemClick(int position) {
   Log.d("catroid", "onListItemClick");
   if (!inContextMode) {
     FormulaEditorFragment formulaEditor =
         (FormulaEditorFragment)
             getActivity()
                 .getSupportFragmentManager()
                 .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
     if (formulaEditor != null) {
       formulaEditor.addUserVariableToActiveFormula(adapter.getItem(position).getName());
       formulaEditor.updateButtonViewOnKeyboard();
     }
     KeyEvent keyEvent = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
     onKey(null, keyEvent.getKeyCode(), keyEvent);
   }
 }
コード例 #2
0
  @Override
  public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_BACK:
        getActivity().findViewById(R.id.bottom_bar).setVisibility(View.GONE);
        ((ScriptActivity) getActivity()).updateHandleAddButtonClickListener();

        FragmentTransaction fragmentTransaction =
            getActivity().getSupportFragmentManager().beginTransaction();
        fragmentTransaction.hide(this);
        FormulaEditorFragment formulaEditorFragment =
            (FormulaEditorFragment)
                getActivity()
                    .getSupportFragmentManager()
                    .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG);
        formulaEditorFragment.updateBrickView();
        fragmentTransaction.show(formulaEditorFragment);
        fragmentTransaction.commit();
        return true;
      default:
        break;
    }
    return false;
  }