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

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

源代码1 项目: reacteu-app   文件: InAppBrowser.java
/**
 * Navigate to the new page
 *
 * @param url to load
 */
private void navigate(final String url) {
    InputMethodManager imm = (InputMethodManager)this.cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);

    this.cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            if (!url.startsWith("http") && !url.startsWith("file:")) {
                InAppBrowser.this.inAppWebView.loadUrl("http://" + url);
            } else {
                InAppBrowser.this.inAppWebView.loadUrl(url);
            }
            InAppBrowser.this.inAppWebView.requestFocus();
        }
    });
}
 
源代码2 项目: VideoOS-Android-SDK   文件: VenvyKeyboardMapper.java
public LuaValue hideKeyboard(U target, Varargs varargs) {
    View view = target.getView();
    if (view == null) {
        return this;
    }
    Context context = view.getContext();
    if (context instanceof Activity) {
        View v = ((Activity) context).getCurrentFocus();
        if (v != null) {
            IBinder token = v.getWindowToken();
            if (token != null) {
                InputMethodManager im = (InputMethodManager) context.getSystemService
                        (Context.INPUT_METHOD_SERVICE);
                im.hideSoftInputFromWindow(token, InputMethodManager.HIDE_NOT_ALWAYS);
            }
        }
    }
    return this;
}
 
源代码3 项目: linphone-android   文件: GroupInfoFragment.java
@Override
public void onResume() {
    super.onResume();

    InputMethodManager inputMethodManager =
            (InputMethodManager) getActivity().getSystemService(INPUT_METHOD_SERVICE);
    if (getActivity().getCurrentFocus() != null) {
        inputMethodManager.hideSoftInputFromWindow(
                getActivity().getCurrentFocus().getWindowToken(), 0);
    }
}
 
源代码4 项目: mvp-helpers   文件: AddTaskFragment.java
public void onFocusChange(View view, boolean isFocused) {
    switch (view.getId()) {
        case R.id.startDateEditText:
        case R.id.dueDateEditText:

            if (isFocused) {
                final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }

            break;
    }
}
 
源代码5 项目: litho   文件: EditTextSpec.java
@OnTrigger(ClearFocusEvent.class)
static void clearFocus(
    ComponentContext c, @State AtomicReference<EditTextWithEventHandlers> mountedView) {
  EditTextWithEventHandlers eventHandler = mountedView.get();
  if (eventHandler != null) {
    eventHandler.clearFocus();
    InputMethodManager imm =
        (InputMethodManager) c.getAndroidContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(eventHandler.getWindowToken(), 0);
  }
}
 
源代码6 项目: IoTgo_Android_App   文件: CordovaWebView.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if(boundKeyCodes.contains(keyCode))
    {
        if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
                this.loadUrl("javascript:cordova.fireDocumentEvent('volumedownbutton');");
                return true;
        }
        // If volumeup key
        else if (keyCode == KeyEvent.KEYCODE_VOLUME_UP) {
                this.loadUrl("javascript:cordova.fireDocumentEvent('volumeupbutton');");
                return true;
        }
        else
        {
            return super.onKeyDown(keyCode, event);
        }
    }
    else if(keyCode == KeyEvent.KEYCODE_BACK)
    {
        return !(this.startOfHistory()) || isButtonPlumbedToJs(KeyEvent.KEYCODE_BACK);
    }
    else if(keyCode == KeyEvent.KEYCODE_MENU)
    {
        //How did we get here?  Is there a childView?
        View childView = this.getFocusedChild();
        if(childView != null)
        {
            //Make sure we close the keyboard if it's present
            InputMethodManager imm = (InputMethodManager) cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(childView.getWindowToken(), 0);
            cordova.getActivity().openOptionsMenu();
            return true;
        } else {
            return super.onKeyDown(keyCode, event);
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
源代码7 项目: BigApp_Discuz_Android   文件: Utils.java
/**
 * 关闭软键盘
 */
public static void closeSoftKeyboard(Context context) {
    InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null && ((Activity) context).getCurrentFocus() != null) {
        inputMethodManager.hideSoftInputFromWindow(((Activity) context).getCurrentFocus()
                .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
源代码8 项目: AndroidUtilCode   文件: KeyboardUtils.java
/**
 * Hide the soft input.
 *
 * @param view The view.
 */
public static void hideSoftInput(@NonNull final View view) {
    InputMethodManager imm =
            (InputMethodManager) Utils.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null) return;
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
源代码9 项目: edx-app-android   文件: SoftKeyboardUtil.java
/**
 * Hides the soft keyboard.
 *
 * @param activity The reference of the activity displaying the keyboard.
 */
public static void hide(@NonNull final Activity activity) {
    final InputMethodManager iManager = (InputMethodManager) activity.
            getSystemService(Context.INPUT_METHOD_SERVICE);
    final View view = activity.getCurrentFocus();
    if (view != null && iManager != null) {
        iManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
 
源代码10 项目: Broadsheet.ie-Android   文件: MakeCommentDialog.java
@Override
public void onClick(View v) {
    if (!validate()) {
        return;
    }

    SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPref.edit();
    editor.putString("email", email.getText().toString());
    editor.putString("commenterName", commenterName.getText().toString());
    editor.putString("commenterUrl", commenterUrl.getText().toString());
    editor.commit();

    MakeCommentRequest makeCommentRequest = new MakeCommentRequest();
    makeCommentRequest.setPostId(postId);
    makeCommentRequest.setEmail(email.getText().toString());
    makeCommentRequest.setCommentUrl(commenterUrl.getText().toString());
    makeCommentRequest.setCommentName(commenterName.getText().toString());
    makeCommentRequest.setCommentBody(commentBody.getText().toString());
    makeCommentRequest.setCommentId(commentId);

    v.setEnabled(false);

    email.clearFocus();
    commenterName.clearFocus();
    commenterUrl.clearFocus();
    commentBody.clearFocus();

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

    ((BaseFragmentActivity) getActivity()).onPreExecute(getResources().getString(R.string.posting_comment));

    spiceManager.execute(makeCommentRequest, new MakeCommentListener());
}
 
源代码11 项目: mobilecloud-15   文件: Utils.java
/**
 * This method is used to hide a keyboard after a user has
 * finished typing the url.
 */
public static void hideKeyboard(Activity activity,
                                IBinder windowToken) {
    InputMethodManager mgr =
        (InputMethodManager) activity.getSystemService
        (Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(windowToken, 0);
}
 
源代码12 项目: FriendCircle   文件: KeyBoardUtil.java
/**
 * 隐藏软键盘
 */
public static void close(View view) {
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
源代码13 项目: commcare-android   文件: DateWidget.java
@Override
public void setFocus(Context context) {
    // Hide the soft keyboard if it's showing.
    InputMethodManager inputManager =
            (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(this.getWindowToken(), 0);
}
 
源代码14 项目: Nimbus   文件: EditorView.java
public void hideKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(lastEditText.getWindowToken(), 0);
}
 
源代码15 项目: mollyim-android   文件: BaseRegistrationFragment.java
protected static void hideKeyboard(@NonNull Context context, @NonNull View view) {
  InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
源代码16 项目: EditTextView   文件: EditTextView.java
private void hideKeyboard(){
    if(ettEditText != null && !isInEditMode()) {
        InputMethodManager imm = (InputMethodManager) getContext().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(ettEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
    }
}
 
源代码17 项目: Saude-no-Mapa   文件: EmergencyFragment.java
@Override
public void dismissKeyboard() {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
}
 
源代码18 项目: WanAndroid   文件: ViewHelper.java
public static void hideKeyboard(@NonNull View view) {
    InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    inputManager.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
 
源代码19 项目: Paginize   文件: BaseInnerPage.java
@Override
public void onDestroy() {
  InputMethodManager imm = (InputMethodManager) getContext()
      .getSystemService(Context.INPUT_METHOD_SERVICE);
  imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
}
 
public void hideKeyboard(Context context, IBinder windowToken) {
    InputMethodManager mgr = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    mgr.hideSoftInputFromWindow(windowToken, 0);
}