android.view.inputmethod.InputMethodManager#showSoftInput ( )源码实例Demo

下面列出了android.view.inputmethod.InputMethodManager#showSoftInput ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: zhangshangwuda   文件: SearchView.java
/**
 * We override this method to be sure and show the soft keyboard if
 * appropriate when the TextView has focus.
 */
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
    super.onWindowFocusChanged(hasWindowFocus);

    if (hasWindowFocus && mSearchView.hasFocus() && getVisibility() == VISIBLE) {
        InputMethodManager inputManager = (InputMethodManager) getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.showSoftInput(this, 0);
        // If in landscape mode, then make sure that
        // the ime is in front of the dropdown.
        if (isLandscapeMode(getContext())) {
            ensureImeVisible(this, true);
        }
    }
}
 
源代码2 项目: ETHWallet   文件: KeyboardUtils.java
public static void showKeyboard(View view) {
    InputMethodManager inputMethodManager
            = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
源代码3 项目: green_android   文件: PinEntryView.java
@Override public boolean onTouchEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        // Make sure this view is focused
        editText.requestFocus();

        // Show keyboard
        InputMethodManager inputMethodManager = (InputMethodManager) getContext()
                                                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(editText, 0);
        return true;
    }
    return super.onTouchEvent(event);
}
 
源代码4 项目: ToolsFinal   文件: DeviceUtils.java
/**
 * 显示输入法
 * @param context
 * @param view
 */
public static void showInputSoftFromWindowMethod(Context context,View view){
    try {
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码5 项目: Loop   文件: DisplayUtility.java
public static void showKeyboard(Context context, View view) {
    view.requestFocus();
    InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
源代码6 项目: Lay-s   文件: SystemTool.java
/**
 * editeText获取键盘
 *
 * @param et
 */
public static void getEditFocus(android.widget.EditText et) {
    et.setFocusableInTouchMode(true);
    et.requestFocus();
    InputMethodManager inputManager = (InputMethodManager) et.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(et, 0);
}
 
源代码7 项目: imsdk-android   文件: KeyboardUtil.java
public static void showKeyboard(final View view) {
    view.requestFocus();
    InputMethodManager inputManager =
            (InputMethodManager) view.getContext().getSystemService(
                    Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(view, 0);
}
 
源代码8 项目: AndroidCommons   文件: KeyboardHelper.java
/**
 * Shows soft keyboard and requests focus for given view.
 */
public static void showSoftKeyboard(Context context, View view) {
    if (view == null) {
        return;
    }

    final InputMethodManager manager = (InputMethodManager)
            context.getSystemService(Context.INPUT_METHOD_SERVICE);
    view.requestFocus();
    manager.showSoftInput(view, 0);
}
 
源代码9 项目: SuperNote   文件: FolderPresenter.java
public void setFoucus(View view){
//        获取 接受焦点的资格
        view.setFocusable(true);
//        获取 焦点可以响应点触的资格
        view.setFocusableInTouchMode(true);
//        请求焦点
        view.requestFocus();
//        弹出键盘
        InputMethodManager manager=(InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.toggleSoftInput(0,0);
        manager.showSoftInput(view,0);
    }
 
private static void showSoftInputUnchecked(View view, InputMethodManager imm, int flags) {
    try {
        Method method = imm.getClass().getMethod("showSoftInputUnchecked", int.class, ResultReceiver.class);
        method.setAccessible(true);
        method.invoke(imm, flags, null);
    } catch (Exception e) {
        //Fallback to public API which hopefully does mostly the same thing
        imm.showSoftInput(view, flags);
    }
}
 
源代码11 项目: NIM_Android_UIKit   文件: InputPanel.java
private void showInputMethod(EditText editTextMessage) {
    editTextMessage.requestFocus();
    //如果已经显示,则继续操作时不需要把光标定位到最后
    if (!isKeyboardShowed) {
        editTextMessage.setSelection(editTextMessage.getText().length());
        isKeyboardShowed = true;
    }

    InputMethodManager imm = (InputMethodManager) container.activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(editTextMessage, 0);

    container.proxy.onInputPanelExpand();
}
 
源代码12 项目: SimpleDialogFragments   文件: CustomListDialog.java
@Override
protected void onDialogShown() {
    updatePosButton();
    if (getArguments().getBoolean(FILTER)){
        // show keyboard
        InputMethodManager imm = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.showSoftInput(mFilterEditText, InputMethodManager.SHOW_IMPLICIT);
        }
    }
}
 
源代码13 项目: SimpleDialogFragments   文件: SimpleInputDialog.java
/**
 * Helper for opening the soft keyboard
 */
public void openKeyboard(){
    InputMethodManager imm = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.showSoftInput(mInput, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    if (searchBox != null) {
        InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(searchBox, InputMethodManager.SHOW_IMPLICIT);
    }
}
 
源代码15 项目: Ticket-Analysis   文件: KeyboardUtils.java
/**
 * 动态显示软键盘
 */
public static void showSoftInput(Context context, EditText edit) {
    edit.setFocusable(true);
    edit.setFocusableInTouchMode(true);
    edit.requestFocus();
    InputMethodManager inputManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.showSoftInput(edit, 0);
}
 
源代码16 项目: mapwize-ui-android   文件: SearchDirectionView.java
public void openFromSearch() {
    fromEditText.requestFocus();
    InputMethodManager imm =(InputMethodManager)
            getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(fromEditText, InputMethodManager.SHOW_IMPLICIT);
    listener.onDirectionFromQueryChange("");
}
 
源代码17 项目: Android-IM   文件: BaseActivity.java
/**
 * 显示软键盘
 * @param v
 */
public static void ShowKeyboard(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);

}
 
源代码18 项目: AndroidBase   文件: InputMethodUtils.java
public static boolean showSoftInput(View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.showSoftInput(view, InputMethodManager.SHOW_FORCED);
}
 
源代码19 项目: javaide   文件: LogcatActivity.java
private void showAddFilterDialog(final FilterAdapter filterAdapter) {

        // show a popup to add a new filter text
        LayoutInflater inflater = getLayoutInflater();
        @SuppressLint("InflateParams")
        final AutoCompleteTextView editText =
                (AutoCompleteTextView) inflater.inflate(R.layout.dialog_new_filter, null, false);

        // show suggestions as the user types
        List<String> suggestions = new ArrayList<>(mSearchSuggestionsSet);
        SortedFilterArrayAdapter<String> suggestionAdapter = new SortedFilterArrayAdapter<>(
                this, R.layout.list_item_dropdown, suggestions);
        editText.setAdapter(suggestionAdapter);

        final MaterialDialog alertDialog = new MaterialDialog.Builder(this)
                .title(R.string.add_filter)
                .positiveText(android.R.string.ok)
                .onPositive(new MaterialDialog.SingleButtonCallback() {
                    @Override
                    public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                        handleNewFilterText(editText.getText().toString(), filterAdapter);
                        dialog.dismiss();
                    }
                })
                .negativeText(android.R.string.cancel)
                .customView(editText, true)
                .build();

        // when 'Done' is clicked (i.e. enter button), do the same as when "OK" is clicked
        editText.setOnEditorActionListener(new OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_DONE) {
                    // dismiss soft keyboard

                    handleNewFilterText(editText.getText().toString(), filterAdapter);

                    alertDialog.dismiss();
                    return true;
                }
                return false;
            }
        });

        alertDialog.show();

        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(editText, 0);

    }
 
源代码20 项目: KeyboardView   文件: SystemUtil.java
/**
 * 打开软键盘
 *
 * @param mEditText 输入框
 * @param mContext  上下文
 */
public static void openKeyboard(EditText mEditText, Context mContext) {
    InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}