Example usage for android.view.inputmethod InputMethodManager showSoftInput

List of usage examples for android.view.inputmethod InputMethodManager showSoftInput

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager showSoftInput.

Prototype

public boolean showSoftInput(View view, int flags) 

Source Link

Document

Synonym for #showSoftInput(View,int,ResultReceiver) without a result receiver: explicitly request that the current input method's soft input area be shown to the user, if needed.

Usage

From source file:com.money.manager.ex.fragment.BaseExpandableListFragment.java

protected void onMenuItemSearchClick(MenuItem item) {
    View searchView = ((SherlockFragmentActivity) getActivity()).getSupportActionBar().getCustomView();
    final EditText edtSearch = (EditText) searchView.findViewById(R.id.editTextSearchView);
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    // se in visualizzazione prendo l'edittext
    if (mDisplayShowCustomEnabled == false) {
        // rendo visibile l'edittext di ricerca
        edtSearch.setText("");
        edtSearch.requestFocus();/*from ww  w .  ja  v a  2s.  c o m*/
        // rendo visibile la keyboard
        imm.showSoftInput(edtSearch, 0);
        item.setActionView(searchView);
        // aggiorno lo stato
        mDisplayShowCustomEnabled = true;
    } else {
        // controllo se ho del testo lo pulisco
        if (TextUtils.isEmpty(edtSearch.getText().toString())) {
            // nascondo la keyboard
            imm.hideSoftInputFromWindow(edtSearch.getWindowToken(), 0);
            // tolgo la searchview
            item.setActionView(null);
            // aggiorno lo stato
            mDisplayShowCustomEnabled = false;
        } else {
            // annullo il testo
            edtSearch.setText(null);
            onPreQueryTextChange("");
        }
    }
}

From source file:com.money.manager.ex.fragment.BaseListFragment.java

protected void onMenuItemSearchClick(MenuItem item) {
    View searchView = ((SherlockFragmentActivity) getActivity()).getSupportActionBar().getCustomView();
    final EditText edtSearch = (EditText) searchView.findViewById(R.id.editTextSearchView);
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    // se in visualizzazione prendo l'edittext
    if (mDisplayShowCustomEnabled == false) {
        // rendo visibile l'edittext di ricerca
        edtSearch.setText("");
        edtSearch.requestFocus();/*www.j a  v  a  2s  .co m*/
        // rendo visibile la keyboard
        imm.showSoftInput(edtSearch, 0);
        item.setActionView(searchView);
        // aggiorno lo stato
        mDisplayShowCustomEnabled = true;
    } else {
        // controllo se ho del testo lo pulisco
        if (TextUtils.isEmpty(String.valueOf(edtSearch.getText()))) {
            // nascondo la keyboard
            imm.hideSoftInputFromWindow(edtSearch.getWindowToken(), 0);
            // tolgo la searchview
            item.setActionView(null);
            // aggiorno lo stato
            mDisplayShowCustomEnabled = false;
        } else {
            // annullo il testo
            edtSearch.setText(null);
            onPreQueryTextChange("");
        }
    }
}

From source file:de.incoherent.suseconferenceclient.activities.HomeActivity.java

@Override
public boolean onMenuItemActionExpand(MenuItem item) {
    final EditText searchText = (EditText) item.getActionView();
    searchText.post(new Runnable() {
        @Override/*  ww w  . java  2  s  . co m*/
        public void run() {
            searchText.requestFocus();
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(searchText, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    return true;
}

From source file:org.cocos2dx.lib.TextInputWraper.java

protected void initView() {
    setEGLConfigChooser(8, 8, 8, 8, 16, 0);
    setZOrderOnTop(true);//w  w  w.  j a v  a 2 s.co m
    getHolder().setFormat(PixelFormat.TRANSLUCENT);
    setFocusableInTouchMode(true);

    textInputWraper = new TextInputWraper(this);

    handler = new Handler() {
        public void handleMessage(Message msg) {
            switch (msg.what) {
            case HANDLER_OPEN_IME_KEYBOARD:
                if (null != mTextField && mTextField.requestFocus()) {
                    mTextField.removeTextChangedListener(textInputWraper);
                    mTextField.setText("");
                    String text = (String) msg.obj;
                    mTextField.append(text);
                    textInputWraper.setOriginText(text);
                    mTextField.addTextChangedListener(textInputWraper);
                    InputMethodManager imm = (InputMethodManager) mainView.getContext()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.showSoftInput(mTextField, 0);
                    Log.d("GLSurfaceView", "showSoftInput");
                }
                break;

            case HANDLER_CLOSE_IME_KEYBOARD:
                if (null != mTextField) {
                    mTextField.removeTextChangedListener(textInputWraper);
                    InputMethodManager imm = (InputMethodManager) mainView.getContext()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0);
                    Log.d("GLSurfaceView", "HideSoftInput");
                }
                break;
            }
        }
    };

    mainView = this;
}

From source file:com.radicaldynamic.groupinform.application.Collect.java

/**
 * Creates and displays a dialog displaying the violated constraint.
 */// ww  w .ja va 2  s  .c om
public void showSoftKeyboard(View v) {
    InputMethodManager inputManager = (InputMethodManager) getBaseContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    IBinder b = v.getWindowToken();
    if (viewToken != null && !viewToken.equals(b)) {
        inputManager.hideSoftInputFromInputMethod(viewToken, 0);
    }

    if (inputManager.isActive(v))
        return;
    inputManager.showSoftInput(v, 0);
    viewToken = b;
}

From source file:com.bonsai.btcreceive.ReceiveFragment.java

public void maybeShowKeyboard() {
    // Called by our parent when it would be good for us to
    // bring up the keyboard.

    mLogger.info("maybeShowKeyboard starting");

    // Does this ever happen?
    if (mFiatAmountEditText == null || mBTCAmountEditText == null)
        return;/*from w  w w  .  j a  va 2 s  .c  o m*/

    // If the user has the value set already we don't want the
    // keyboard.
    if (mValueSet)
        return;

    mFiatAmountEditText.setFocusable(true);
    mFiatAmountEditText.setFocusableInTouchMode(true);
    mBTCAmountEditText.setFocusable(true);
    mBTCAmountEditText.setFocusableInTouchMode(true);

    Activity activity = getActivity();
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (mUserSetAmountFiat) {
        mLogger.info("maybeShowKeyboard fiat");
        imm.showSoftInput(mFiatAmountEditText, InputMethodManager.SHOW_IMPLICIT);
        mFiatAmountEditText.requestFocus();
    } else {
        mLogger.info("maybeShowKeyboard btc");
        imm.showSoftInput(mBTCAmountEditText, InputMethodManager.SHOW_IMPLICIT);
        mBTCAmountEditText.requestFocus();
    }
}

From source file:de.enlightened.peris.NewPost.java

private void setColor(final String color) {

    final LinearLayout llPicker = (LinearLayout) findViewById(R.id.profileColorPicker);
    llPicker.setVisibility(View.GONE);

    final String selectedText = this.bodyInputter.getText().toString()
            .substring(this.colorSelectionStart, this.colorSelectionEnd).trim();

    final String firstPart = this.bodyInputter.getText().toString().substring(0, this.colorSelectionStart);
    final String secondPart = this.bodyInputter.getText().toString().substring(this.colorSelectionEnd,
            this.bodyInputter.getText().toString().length());
    this.bodyInputter.setText(firstPart + "[color=" + color + "]" + selectedText + "[/color]" + secondPart);
    this.bodyInputter.setSelection(this.colorSelectionEnd + ("[color=" + color + "]").length());

    final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this.bodyInputter, 0);
    this.colorPickerOpen = false;
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@Override
public void showKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mConsoleView.requestFocus();/*w  ww .java  2 s .  c  o  m*/
    if (imm != null) {
        imm.showSoftInput(mConsoleView, InputMethodManager.SHOW_IMPLICIT);
    }
}

From source file:de.enlightened.peris.NewPost.java

@Override
public final boolean onKeyDown(final int keyCode, final KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (this.colorPickerOpen) {

            final LinearLayout llPicker = (LinearLayout) findViewById(R.id.profileColorPicker);
            llPicker.setVisibility(View.GONE);

            final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(this.bodyInputter, 0);

            this.colorPickerOpen = false;
            return true;
        }/*  w  w  w. j  a  va  2 s.  co m*/
    }

    return super.onKeyDown(keyCode, event);
}

From source file:pl.ipebk.tabi.presentation.ui.search.SearchActivity.java

@Override
public void showKeyboard() {
    InputMethodManager keyboard = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    searchEditText.requestFocus();/*from  w  w  w  .  ja v  a 2  s .c  om*/
    keyboard.showSoftInput(searchEditText, 0);
}