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:mobi.cangol.mobile.base.BaseFragmentActivity.java

@Override
public void showSoftInput(EditText editText) {
    editText.requestFocus();/*from   ww w . j a  v  a2 s  .  co m*/
    InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(editText, 0);
    editText.setText(null);
}

From source file:com.example.skode6.scanenvy.MainActivity.java

private AlertDialog enterDialog(final EditText edit) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);

    edit.setKeyListener(new DigitsKeyListener());
    final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, InputMethodManager.SHOW_IMPLICIT);
    //edit.setFocusableInTouchMode(true);
    edit.setFocusable(true);//from  www.  ja v  a 2s. c o  m
    //edit.setOnClickListener(clickText());
    //edit.requestFocusFromTouch();
    edit.requestFocus();

    dialog.setView(edit);
    dialog.setCancelable(true);
    dialog.setTitle("Enter UPC");
    dialog.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String upc = edit.getText().toString();
            try {
                Product p = run.lookUp(upc);
                adapter.add(p);
                //run.addProduct(p);
            } catch (IOException e) {
                Toast error = Toast.makeText(getApplicationContext(), "Couldn't find" + upc, Toast.LENGTH_LONG);
                error.show();
            }
        }
    });
    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    return dialog.create();
}

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

private void openKeyboard() {
    InputMethodManager imm = (InputMethodManager) mParentActivity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mInputEditText, 0);
    Log.d("Cocos2dxEditBox", "openKeyboard");
}

From source file:hku.fyp14017.blencode.ui.dialogs.UploadProjectDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getActivity())
            .inflate(hku.fyp14017.blencode.R.layout.dialog_upload_project, null);

    projectRename = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.tv_project_rename);
    projectDescriptionField = (EditText) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.project_description_upload);
    projectUploadName = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.project_upload_name);
    sizeOfProject = (TextView) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.dialog_upload_size_of_project);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView)
            .setTitle(hku.fyp14017.blencode.R.string.upload_project_dialog_title)
            .setPositiveButton(hku.fyp14017.blencode.R.string.upload_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleUploadButtonClick();
                        }//from   w  w  w  .  j a v  a 2 s.  c o  m
                    })
            .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleCancelButtonClick();
                        }
                    })
            .create();

    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            initListeners();

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    initControls();

    return dialog;
}

From source file:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java

private void setKeyboardVisibilityForUrl(boolean visible) {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (visible) {
        imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
    } else {// w ww. ja  v  a  2  s.  c o m
        imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
    }
}

From source file:com.ternup.caddisfly.fragment.FormFragment.java

@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
    if (EditorInfo.IME_ACTION_DONE == EditorInfo.IME_ACTION_DONE) {
        // Return input text to activity

        String resultPlace = mPlaceEditText.getEditText().getText().toString().trim();
        //String address = mAddressEdit.getText().toString().trim();
        //int resultSource = mSourceSpinner.getSelectedItemPosition();

        if (resultPlace.isEmpty()) {
            mPlaceEditText.getEditText().setError("Please enter a Place name");
            mPlaceEditText.getEditText().post(new Runnable() {
                public void run() {
                    mPlaceEditText.getEditText().requestFocusFromTouch();
                    InputMethodManager lManager = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    lManager.showSoftInput(mPlaceEditText.getEditText(), 0);
                }/*from  w ww .  j a v  a  2 s. c  o m*/
            });
        } else {
            listener.onPageComplete();
        }

        /*else if (address.isEmpty()) {
        mAddressEdit.setError("Please enter an Address");
        mAddressEdit.post(new Runnable() {
            public void run() {
                mAddressEdit.requestFocusFromTouch();
                InputMethodManager lManager = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                lManager.showSoftInput(mAddressEdit, 0);
            }
        });
        } else if (resultSource == 0) {
        mPlaceEdit.setError(null);
        Toast toast = Toast
                .makeText(getActivity(), "Please select a Source type", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.TOP, 0, 40);
        toast.show();
        } else {
                
        ContentValues values = new ContentValues();
        //values.put(TestTable.COLUMN_ADDRESS, placeEdit.getText().toString().trim());
        //values.put(TestTable.COLUMN_SOURCE, resultSource - 1);
                
        //Uri uri = ContentUris.withAppendedId(LocationContentProvider.CONTENT_URI, mId);
        //mContext.getContentResolver().update(uri, values, null, null);
                
        long locationId = saveResult();
                
        AddressDialogListener activity = (AddressDialogListener) getTargetFragment();
        activity.onFinishEditDialog(locationId);
        dialog.dismiss();
                
        return true;
                
        }*/
    }
    return false;
}

From source file:com.example.skode6.scanenvy.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    final SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search));
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override//  w  w w . ja v  a 2s  .  com
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            //loadHistory(query);
            return false;
        }
    });
    if (searchView != null) {
        searchView.setIconifiedByDefault(true);
        searchView.setFocusable(true);
        searchView.setIconified(true);
        searchView.setOnSearchClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(searchView, InputMethodManager.HIDE_IMPLICIT_ONLY);
                fabToolbar.hide();
            }
        });
        searchView.setFocusableInTouchMode(false);
        searchView.setOnClickListener(clickText());
        searchView.setOnFocusChangeListener(focusText());
    } else {
        Toast toast = Toast.makeText(getApplicationContext(), "Not Null", Toast.LENGTH_SHORT);
        toast.show();
    }
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.king.base.BaseDialogFragment.java

/**
 * //from  ww w  .  j  av a  2  s . co  m
 *
 * @param v
 */
public void showInputMethod(final EditText v) {

    v.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
}

From source file:org.chromium.content_shell.Shell.java

private void setKeyboardVisibilityForUrl(boolean visible) {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (visible) {
        imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
    } else {//from   ww  w.  jav  a 2 s  . c o  m
        imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
    }
}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysCloudFragment.java

private void toggleKeyboard(boolean show) {
    if (getActivity() == null) {
        return;/* w w  w  .j  a  v a 2  s .  c  o m*/
    }
    InputMethodManager inputManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus
    View v = getActivity().getCurrentFocus();
    if (v == null) {
        return;
    }

    if (show) {
        inputManager.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
    } else {
        inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }
}