Java Code Examples for android.app.Dialog#getCurrentFocus()

The following examples show how to use android.app.Dialog#getCurrentFocus() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppHelper.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
public static void hideSoftInput(Dialog dialog) {
    View view = dialog.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
 
Example 2
Source File: Util.java    From HappyBubble with Apache License 2.0 5 votes vote down vote up
/**
 * 隐藏软键盘
 */
public static void hide(Dialog dialog)
{
    View view = dialog.getCurrentFocus();
    if (view instanceof TextView)
    {
        InputMethodManager mInputMethodManager = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        mInputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
    }
}
 
Example 3
Source File: HideUtil.java    From HideKeyboard with Apache License 2.0 5 votes vote down vote up
/**
 * Forced hidden keyboard
 *
 * @param dialog
 */
public static void hideDialogSoftKeyboard(Dialog dialog) {
    if (null == dialog) {
        throw new RuntimeException("参数错误");
    }
    View view = dialog.getCurrentFocus();
    if (null != view) {
        InputMethodManager inputMethodManager = (InputMethodManager) dialog.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
Example 4
Source File: AppHelper.java    From EhViewer with Apache License 2.0 5 votes vote down vote up
public static void hideSoftInput(Dialog dialog) {
    View view = dialog.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) dialog.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}