Example usage for android.view.inputmethod InputMethodManager toggleSoftInput

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

Introduction

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

Prototype

public void toggleSoftInput(int showFlags, int hideFlags) 

Source Link

Document

This method toggles the input method window display.

Usage

From source file:com.simplaapliko.trips.presentation.fragment.BaseFragment.java

protected void showKeyboard(SearchView view) {
    view.requestFocus();/*from   w w  w  . ja  va 2s.c  o  m*/
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Open the soft keyboard//from  ww w . ja v  a2  s  .c  om
 */
public static void openKeyboard(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:org.badreader.client.fragments.BaseFragment.java

protected void showKeyboard(final Activity _context, final EditText _edit) {
    final InputMethodManager imm = (InputMethodManager) _context.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (android.os.Build.VERSION.SDK_INT < 11) {
        imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
    }/*  w  w  w .j  a v  a  2 s . c o m*/

    _edit.postDelayed(new Runnable() {
        public void run() {
            _edit.requestFocus();
            imm.showSoftInput(_edit, 0);
        }
    }, 100);
}

From source file:edu.rowan.app.fragments.FoodCommentFragment.java

public void onStart() {
    super.onStart();
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}

From source file:org.akvo.caddisfly.sensor.ec.EditSensorIdentity.java

@NonNull
@Override//from  ww  w  . j av  a  2  s.com
public Dialog onCreateDialog(Bundle savedInstanceState) {

    final Context context = getActivity();

    LayoutInflater i = getActivity().getLayoutInflater();

    @SuppressLint("InflateParams")
    View view = i.inflate(R.layout.fragment_edit_sensor_identity, null);

    editId = (EditText) view.findViewById(R.id.editId);

    editId.requestFocus();

    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

    AlertDialog.Builder b = new AlertDialog.Builder(getActivity()).setTitle(R.string.sensorDetails)
            .setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    closeKeyboard(context, editId);
                    dismiss();
                }
            });

    b.setView(view);
    return b.create();
}

From source file:calibrationapp.spectoccular.com.keyboardtolinux.MainActivity.java

private void showSoftInput() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:com.doctorapp.doctorappclient.basic.ui.fragment.CaseHistoryFragment.java

private void notifyStartSearching(String text) {
    //??/*  w  w w . j  av a  2s . c  o  m*/
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
}

From source file:de.appetites.android.menuItemSearchAction.MenuItemSearchAction.java

private void createMenuItem(Menu menu, Drawable drawable, final LinearLayout list) {
    ActionBar.LayoutParams layoutParams = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    setLayoutParams(layoutParams);/*from  ww  w  .  ja v a  2s. co  m*/

    setHint(R.string.menu_item_search_action_hint);

    searchItem = menu.add(R.string.menu_item_search_action_menu_text).setIcon(drawable);
    searchItem.setActionView(this).setTitle("Search");
    searchItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            // open keyboard
            list.setVisibility(View.VISIBLE);
            MenuItemSearchAction.this.setText("");
            MenuItemSearchAction.this.requestFocus();

            MenuItemSearchAction.this.postDelayed(new Runnable() {
                @Override
                public void run() {
                    InputMethodManager imm = (InputMethodManager) context
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
                }
            }, 200);
            return true;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            // close keyboard
            list.setVisibility(View.GONE);
            InputMethodManager imm = (InputMethodManager) context
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(MenuItemSearchAction.this.getWindowToken(), 0);

            return true;
        }
    });

    setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                // perform Search
                searchPerformListener.performSearch(MenuItemSearchAction.this.getText().toString());

                searchItem.collapseActionView();
                return true;
            }
            return false;
        }
    });
}

From source file:luxsyp.corona.com.base.ui.activity.HomeActivity.java

private void initSearchButton() {
    search_fab.setClickable(true);//  w w w .  jav  a  2  s  . co m
    search_fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            search_fab.setClickable(true);
            search_fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    try {
                        new MaterialDialog.Builder(HomeActivity.this).title(R.string.movie_name_search)
                                .content(R.string.movie_name_search)
                                .inputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME
                                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS)
                                .input(R.string.movie_name_search, R.string.no_prefill,
                                        new MaterialDialog.InputCallback() {
                                            @Override
                                            public void onInput(MaterialDialog dialog, CharSequence input) {
                                                homeFragment.doSearch(input.toString());
                                                InputMethodManager imm = (InputMethodManager) getSystemService(
                                                        Context.INPUT_METHOD_SERVICE);
                                                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
                                            }
                                        })
                                .show();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
    });
}

From source file:com.huijimuhe.commonlayout.xc.detail.xcDetailContainerFragment.java

protected void showKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
}