Java 类android.view.inputmethod.InputMethodManager 实例源码

项目:AndroidBackendlessChat    文件:DialogUtils.java   
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId) {
        if (mEditText.getText().toString().isEmpty())
        {
            SuperToast toast = chatSDKUiHelper.getAlertToast();
            toast.setGravity(Gravity.TOP, 0, 0);
            toast.setText("Please enter chat name");
            toast.show();
            return true;
        }

        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
                Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);

        // Return input text to activity
        listener.onFinished(mEditText.getText().toString());
        this.dismiss();
        return true;
    }
    return false;
}
项目:simpleSDL    文件:SDLActivity.java   
@Override
public void run() {
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING);
    params.leftMargin = x;
    params.topMargin = 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);

    mScreenKeyboardShown = true;
}
项目:Typesetter    文件:AndroidUtils.java   
public static void hideKeyboard(@NonNull Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
项目:DizzyPassword    文件:PswInputView.java   
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    if (mFocusAnim != null) {
        mFocusAnim.end();
    }
    if (gainFocus) {
        mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, (float) (getWidth() - 2 * mRoundRadius));
        input.showSoftInput(this, InputMethodManager.SHOW_FORCED);
    } else {
        mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, 0);
        input.hideSoftInputFromInputMethod(this.getWindowToken(), 0);
    }
    mFocusAnim.setDuration(1000).setInterpolator(new OvershootInterpolator());
    mFocusAnim.start();
}
项目:AppCommonFrame    文件:KeyboardUtils.java   
/**
 * Hides the soft keyboard from screen
 *
 * @param view Usually the EditText, but in dynamically  layouts you should pass the layout
 * instead of the EditText
 * @return true, if keyboard has been hidden, otherwise false (i.e. the keyboard was not displayed
 * on the screen or no Softkeyboard because device has hardware keyboard)
 */
public static boolean hideKeyboard(View view) {

  if (view == null) {
    throw new NullPointerException("View is null!");
  }

  try {
    InputMethodManager imm =
        (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    if (imm == null) {
      return false;
    }

    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  } catch (Exception e) {
    return false;
  }

  return true;
}
项目:Nird2    文件:TextInputView.java   
public void showSoftKeyboard() {
    if (isKeyboardOpen()) return;

    if (ui.emojiDrawer.isShowing()) {
        postOnKeyboardOpen(new Runnable() {
            @Override
            public void run() {
                hideEmojiDrawer();
            }
        });
    }
    ui.editText.post(new Runnable() {
        @Override
        public void run() {
            ui.editText.requestFocus();
            InputMethodManager imm =
                    (InputMethodManager) getContext()
                            .getSystemService(INPUT_METHOD_SERVICE);
            imm.showSoftInput(ui.editText, SHOW_IMPLICIT);
        }
    });
}
项目:QuranKeyboard    文件:QuranKeyboardIME.java   
/**
 * Main initialization of the input method component.  Be sure to call
 * to super class.
 */
@Override public void onCreate() {
    super.onCreate();
    mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    mWordSeparators = getResources().getString(R.string.word_separators);
    mSuggestions = EMPTY_LIST;
    mQuranSuggestions = EMPTY_MLIST;
    mSavedPreSpaces = 0;

    try {
        mQuranSearch = new QuranSearch(this);
    } catch (IOException |SecurityException e) {
        mQuranSearch = null;
        Toast.makeText(this, "Quran Search disabled, File not found!", Toast.LENGTH_LONG).show();
        // TODO disable/gray the Moshaf/shift key & disable/grey Prefs
        if (DEBUG) e.printStackTrace();
    }

    if (mQuranSearch != null) {
        PreferenceManager.setDefaultValues(this, R.xml.ime_preferences, false);

        setUthmaniTypeFace(Typeface.createFromAsset(getAssets(), "UthmanicHafs.otf"));
    }
}
项目:Android_watch_magpie    文件:AddValueFragment.java   
private void setCancelAction(Button cancelButton, final EditText dateEditText,
                             final EditText timeEditText, final TextInputLayout... textInputLayouts) {
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (TextInputLayout textInputLayout : textInputLayouts) {
                textInputLayout.getEditText().setText("");
                textInputLayout.clearFocus();
                // Hide the keyboard
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(textInputLayout.getEditText().getWindowToken(), 0);
            }
            dateEditText.setText("");
            timeEditText.setText("");
        }
    });
}
项目:MobileAppForPatient    文件:GuiUtils.java   
public static void setKeypadVisibility(Context context, EditText inputNote, int visibility) {
    InputMethodManager imm = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    switch (visibility) {
        case View.VISIBLE:
            // 開啟鍵盤
            imm.showSoftInput(inputNote, InputMethodManager.SHOW_IMPLICIT);
            break;
        case View.GONE:
        case View.INVISIBLE:
            // 關閉鍵盤
            imm.hideSoftInputFromWindow(inputNote.getWindowToken(), 0);
            break;
    } /* end of switch */
}
项目:EditorImageAndText    文件:PostActivity.java   
/**
 * EditText获取焦点并显示软键盘
 */
public void showSoftInputFromWindow(EditText editText) {
    //添加文字edittext弹出软键盘
    editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            InputMethodManager imm = (InputMethodManager) PostActivity.this
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
        }

    }, 100);//这里的时间大概是自己测试的
}
项目:Aequorea    文件:MaterialSearchView.java   
public void showKeyboard(View view) {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1 && view.hasFocus()) {
        view.clearFocus();
    }
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) view.getContext()
        .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.showSoftInput(view, 0);
    }
}
项目:AOSP-Kayboard-7.1.2    文件:RichInputMethodManager.java   
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
    final InputMethodManager imm = mImmWrapper.mImm;
    final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
    final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis);
    if (currentIndex == INDEX_NOT_FOUND) {
        Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
                + getInputMethodInfoOfThisIme().getPackageName());
        return false;
    }
    final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
    final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi,
            true /* allowsImplicitlySelectedSubtypes */);
    if (enabledSubtypes.isEmpty()) {
        // The next IME has no subtype.
        imm.setInputMethod(token, nextImi.getId());
        return true;
    }
    final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
    imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
    return true;
}
项目:ModPE-IDE-Source    文件:LModActivity.java   
@SuppressWarnings("ConstantConditions")
private void closeKeyBoard() throws NullPointerException {
    InputMethodManager inputManager =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    IBinder windowToken = getCurrentFocus().getWindowToken();
    int hideType = InputMethodManager.HIDE_NOT_ALWAYS;
    inputManager.hideSoftInputFromWindow(windowToken, hideType);
}
项目:live_master    文件:IjkPlayer.java   
private void HideSoftInput(IBinder token) {
    if (token != null) {
        InputMethodManager manager = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(token,
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
项目:zabbkit-android    文件:AddHostActivity.java   
private void performAdd() {
    InputMethodManager imm = (InputMethodManager) getSystemService(
            Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(editUrl.getWindowToken(), 0);

    showDialog();
    final Map<String, Object> params = new ArrayMap<String, Object>();
    params.put(Constants.PREFS_USER, editLogin.getText().toString());
    params.put(Constants.PREFS_PASSWORD, editPass.getText().toString());
    Communicator.getInstance().login(params,
            collectUrl(editUrl.getText().toString()), this);
}
项目:behe-keyboard    文件:PCKeyboard.java   
/**
 * Main initialization of the input method component. Be sure to call
 * to super class.
 */

@Override public void onCreate() {
    super.onCreate();
    mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    mWordSeparators = getResources().getString(R.string.word_separators);
    final TextServicesManager tsm = (TextServicesManager) getSystemService(
            Context.TEXT_SERVICES_MANAGER_SERVICE);
    mScs = tsm.newSpellCheckerSession(null, null, this, true);
}
项目:DizzyPassword    文件:PswInputView.java   
/**
     * 初始化相关参数
     */
    void init(AttributeSet attrs) {
        final float dp = getResources().getDisplayMetrics().density;
        this.setFocusable(true);
        this.setFocusableInTouchMode(true);
        input = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        result = new ArrayList<>();
        if (attrs != null) {
            TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.PswInputView);
//            mBorderColor = ta.getColor(R.styleable.PswInputView_border_color, getResources().getColor(R.color.color_13));
            mBorderColor = ta.getColor(R.styleable.PswInputView_border_color, ThemeUtils.getPrimaryColor(AppManager.getAppManager().currentActivity()));
            mDotColor = ta.getColor(R.styleable.PswInputView_dot_color, getResources().getColor(R.color.color_bg));
            count = ta.getInt(R.styleable.PswInputView_count, 6);
            ta.recycle();
        } else {
            mBorderColor = Color.LTGRAY;
            mDotColor = Color.GRAY;
            count = 6;//默认6位密码
        }
        size = (int) (dp * 30);//默认30dp一格
        //color
        mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mBorderPaint.setStrokeWidth(2);
        mBorderPaint.setStyle(Paint.Style.STROKE);
        mBorderPaint.setColor(mBorderColor);
        mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mDotPaint.setStrokeWidth(3);
        mDotPaint.setStyle(Paint.Style.FILL);
        mDotPaint.setColor(mDotColor);
        mRoundRect = new RectF();
        mRoundRadius = (int) (5 * dp);
        mFocusLineLength = 0;
        this.setOnKeyListener(new MyKeyListener());
    }
项目:Nird2    文件:TextInputView.java   
public void showSoftKeyboard() {
    if (isKeyboardOpen()) return;

    if (ui.emojiDrawer.isShowing()) {
        postOnKeyboardOpen(new Runnable() {
            @Override
            public void run() {
                hideEmojiDrawer();
            }
        });
    }
    ui.editText.post(new Runnable() {
        @Override
        public void run() {
            ui.editText.requestFocus();
            InputMethodManager imm =
                    (InputMethodManager) getContext()
                            .getSystemService(INPUT_METHOD_SERVICE);
            imm.showSoftInput(ui.editText, SHOW_IMPLICIT);
        }
    });
}
项目:android-project-gallery    文件:ViewUtils.java   
/**
 * 隐藏输入法, 在Activity的维度
 * 
 * @param activity
 */
public static void hideSoftInput(Activity activity)
{
    try
    {
        ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
                activity.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
    catch (Exception e)
    {
        // 避免可能不对手机的兼容异常
        e.printStackTrace();
    }
}
项目:mvparms    文件:DeviceUtils.java   
/**
 * 隐藏软键盘
 *
 * @param context
 * @param view
 */
public static void hideSoftKeyboard(Context context, View view) {
    if (view == null)
        return;
    InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(
            Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive())
        inputMethodManager.hideSoftInputFromWindow(
                view.getWindowToken(), 0);
}
项目:boohee_v5.6    文件:SearchView.java   
void showSoftInputUnchecked(InputMethodManager imm, View view, int flags) {
    if (this.showSoftInputUnchecked != null) {
        try {
            this.showSoftInputUnchecked.invoke(imm, new Object[]{Integer.valueOf(flags), null});
            return;
        } catch (Exception e) {
        }
    }
    imm.showSoftInput(view, flags);
}
项目:civify-app    文件:CreateIssueActivity.java   
private void hideSoftKeyboard() {
    InputMethodManager inputMethodManager =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager
            .hideSoftInputFromWindow(findViewById(android.R.id.content).getWindowToken(), 0);

}
项目:redpacketui-open    文件:RPBaseFragment.java   
/**
 * close soft keyboard
 */
protected void closeSoftKeyboard() {
    View view = getActivity().getWindow().peekDecorView();
    if (view != null) {
        InputMethodManager manager = (InputMethodManager) mContext.getSystemService(Activity.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
项目:instamaterial    文件:BaseActivity.java   
protected void hideKeyboard() {
  View view = getCurrentFocus();
  if (view != null) {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  }
}
项目:android-numberpickercompat    文件:NumberPicker.java   
/**
 * Hides the soft input if it is active for the input text.
 */
private void hideSoftInput() {
    InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
        inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        mInputText.setVisibility(View.INVISIBLE);
    }
}
项目:DroidPlugin    文件:IInputMethodManagerBinderHook.java   
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
    super.onInstall(classLoader);
    Object obj = FieldUtils.readStaticField(InputMethodManager.class, "sInstance");
    if (obj != null) {
        FieldUtils.writeStaticField(InputMethodManager.class, "sInstance", null);
    }
    mHostContext.getSystemService(Context.INPUT_METHOD_SERVICE);
}
项目:GitHub    文件:ViewUtil.java   
/**
 * 隐藏软键盘
 */
public static void hideKeyboard(Activity c) {
    try {
        InputMethodManager imm = (InputMethodManager) c
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(c.getCurrentFocus().getWindowToken(), 0);
    } catch (NullPointerException e) {
    }
}
项目:CryptoVoice    文件:Main.java   
private void setMainView(){
    setContentView(R.layout.activity_main);
    TextView tv = (TextView) findViewById(R.id.textView2);
    final EditText number = (EditText) findViewById(R.id.editText);
    number.requestFocus();
    InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
    sb = Snackbar.make(findViewById(R.id.content_main), "Unknown error", Snackbar.LENGTH_INDEFINITE);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    final IControlChannelListener main = this;
    tv.setText(Integer.toString(cc.getNumber()));
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if(cc.activeCall()){
                cc.hangup();
                return;
            }
            if (number.getText().length() != 0){
                cc.dial(Integer.parseInt(number.getText().toString()));
                setInCallView();
            }
        }
    });
    final Button contactSelect =  (Button) findViewById(R.id.buttonContact);
    contactSelect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI);
            startActivityForResult(contactPickerIntent, RESULT_PICK_CONTACT);
        }
    });
    if(wakeLock.isHeld()) {
        wakeLock.release();
    }
}
项目:ShangHanLun    文件:ShowFragment.java   
public void hideKeyboard() {
    searchEditText.clearFocus();
    // getActivity().getWindow().setSoftInputMode(
    // WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    InputMethodManager imm = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(searchEditText.getWindowToken(), 0);
    // this is a valuable method.
    // imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(),0);
    // tableView.requestFocus();
}
项目:Tribe    文件:EaseBaseFragment.java   
protected void hideSoftKeyboard() {
    if (getActivity().getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (getActivity().getCurrentFocus() != null)
            inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
项目:rongyunDemo    文件:AMUtils.java   
public static void onInactive(Context context, EditText et) {

        if (et == null)
            return;

        et.clearFocus();
        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
    }
项目:Sprog-App    文件:MainActivity.java   
public void disableSearch(){
    search_box.setVisibility(View.GONE);
    search_text.setText("");
    findViewById(R.id.toggle_search).setBackgroundColor(Color.TRANSPARENT);
    ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
            .hideSoftInputFromWindow(search_box.getWindowToken(), 0);
}
项目:utils-android    文件:UiUtils.java   
/**
 * прячет клавиатуру
 */
public static void hideKeyboard(@Nullable Activity activity) {
    if (activity != null) {
        InputMethodManager imm =
                (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        View focusedView = activity.getCurrentFocus();
        if (focusedView != null) {
            imm.hideSoftInputFromWindow(focusedView.getWindowToken(), 0);
        } else {
            imm.hideSoftInputFromWindow((new View(activity)).getWindowToken(), 0);
        }
    }
}
项目:boohee_v5.6    文件:EditPage.java   
private void hideSoftInput() {
    try {
        ((InputMethodManager) this.activity.getSystemService("input_method")).hideSoftInputFromWindow(this.etContent.getWindowToken(), 0);
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
项目:Review-    文件:TDevice.java   
public static void hideSoftKeyboard(View view) {
    if (view == null)
        return;
    ((InputMethodManager) BaseApplication.context().getSystemService(
            Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(
            view.getWindowToken(), 0);
}
项目:aarLibrary    文件:SupportFragment.java   
/**
 * 显示软键盘,调用该方法后,会在onPause时自动隐藏软键盘
 */
protected void showSoftInput(final View view) {
    if (view == null) return;
    initImm();
    view.requestFocus();
    mNeedHideSoft = true;
    view.postDelayed(new Runnable() {
        @Override
        public void run() {
            mIMM.showSoftInput(view, InputMethodManager.SHOW_FORCED);
        }
    }, SHOW_SPACE);
}
项目:mobile-grammar    文件:AllArticlesListViewActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_show_search_field) {
        // change layout params to show search text
        EditText searchTextView = (EditText) findViewById(R.id.editTextSearchField);
        // text listener to use entered characters in search
        searchTextView.addTextChangedListener(textWatcher);
        // input manager to start or hide keayboard
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

        if (searchTextView.getLayout().getWidth() == 0) {
            // show text for entering search field
            searchTextView.setLayoutParams(new Toolbar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            // ... and set focus
            searchTextView.requestFocus();
            // show keyboard
            imm.showSoftInput(searchTextView, InputMethodManager.SHOW_IMPLICIT);
        } else {
            if (searchTextView.getText().toString().length() > 0) return true;
            // hide search field
            searchTextView.setLayoutParams(new Toolbar.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT));
            // hide keyboard
            imm.hideSoftInputFromWindow(searchTextView.getWindowToken(), 0);
        }
        return true;
    } else if (id == R.id.about_program_menu_item) {
        Intent intent = new Intent(getApplicationContext(), AboutProgramActivity.class);
        startActivity(intent);
        return true;
    }

    return super.onOptionsItemSelected(item);
}
项目:airgram    文件:AndroidUtilities.java   
public static void showKeyboard(View view) {
    if (view == null) {
        return;
    }
    try {
        InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
项目:PokeMusic    文件:ImeUtils.java   
public static void showIme( View view) {
    InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService
            (Context.INPUT_METHOD_SERVICE);
    // the public methods don't seem to work for me, so… reflection.
    try {
        Method showSoftInputUnchecked = InputMethodManager.class.getMethod(
                "showSoftInputUnchecked", int.class, ResultReceiver.class);
        showSoftInputUnchecked.setAccessible(true);
        showSoftInputUnchecked.invoke(imm, 0, null);
    } catch (Exception e) {
        // ho hum
    }
}
项目:android-lite-utils    文件:KeyBoardUtils.java   
/**
 * 强制隐藏输入法键盘
 *
 * @param edittext
 */
public void hideKeybord(EditText edittext) {
    InputMethodManager inputMethodManager = (InputMethodManager)
            edittext.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
    }
}