Exemplo n.º 1
0
  /** @param view */
  public static void showSoftKeyboard(final View view) {
    if (view == null) {
      return;
    }

    final Runnable action =
        new Runnable() {
          @Override
          public void run() {
            final InputMethodManager imm =
                (InputMethodManager)
                    view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
          }
        };

    final View.OnFocusChangeListener restoreOnFocusChangeListener = view.getOnFocusChangeListener();

    final View.OnFocusChangeListener temporaryOnFocusChangeListener =
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(final View v, final boolean hasFocus) {
            view.setOnFocusChangeListener(restoreOnFocusChangeListener);
            view.postDelayed(action, 25);
          }
        };

    view.setOnFocusChangeListener(temporaryOnFocusChangeListener);
    view.requestFocus();
  }
Exemplo n.º 2
0
    @Override
    public void run() {
      AbsoluteLayout.LayoutParams params =
          new AbsoluteLayout.LayoutParams(w, h + HEIGHT_PADDING, x, y);

      if (mTextEdit == null) {
        mTextEdit = new DummyEdit(getContext());

        mLayout.addView(mTextEdit, params);
      } else {
        mTextEdit.setLayoutParams(params);
      }

      mTextEdit.setVisibility(View.VISIBLE);
      mTextEdit.requestFocus();

      InputMethodManager imm =
          (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
      imm.showSoftInput(mTextEdit, 0);
    }