当前位置: 首页>>代码示例>>Java>>正文


Java InputMethodManager.hideSoftInputFromWindow方法代码示例

本文整理汇总了Java中android.view.inputmethod.InputMethodManager.hideSoftInputFromWindow方法的典型用法代码示例。如果您正苦于以下问题:Java InputMethodManager.hideSoftInputFromWindow方法的具体用法?Java InputMethodManager.hideSoftInputFromWindow怎么用?Java InputMethodManager.hideSoftInputFromWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.inputmethod.InputMethodManager的用法示例。


在下文中一共展示了InputMethodManager.hideSoftInputFromWindow方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hideSoftKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void hideSoftKeyboard(View view) {
    if (view == null) {
        return;
    }
    View mFocusView = view;

    Context context = view.getContext();
    if (context != null && context instanceof Activity) {
        Activity activity = ((Activity) context);
        mFocusView = activity.getCurrentFocus();
    }
    if (mFocusView == null) {
        return;
    }
    mFocusView.clearFocus();
    InputMethodManager manager = (InputMethodManager) mFocusView.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    manager.hideSoftInputFromWindow(mFocusView.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:20,代码来源:TDevice.java

示例2: showSoftKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
 * Shows/ hides soft input (soft keyboard).
 * 
 * @param view
 *            {@link View}.
 * @param show
 *            {@code true} or {@code false}. If {@code true}, this method
 *            will use a {@link Runnable} to show the IMM. So you don't need
 *            to use it, and consider using
 *            {@link View#removeCallbacks(Runnable)} if you want to cancel.
 */
public static void showSoftKeyboard(final View view, final boolean show) {
    final InputMethodManager imm = (InputMethodManager) view.getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm == null)
        return;

    if (show) {
        view.post(new Runnable() {

            @Override
            public void run() {
                imm.showSoftInput(view, 0, null);
            }// run()
        });
    } else
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0, null);
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:29,代码来源:Ui.java

示例3: onEditorAction

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
    if (null == getActivity()) return false;
    FragmentTransaction transactionPhoto = getChildFragmentManager().beginTransaction();
    FragmentTransaction transactionCollection = getChildFragmentManager().beginTransaction();
    FragmentTransaction transactionUser = getChildFragmentManager().beginTransaction();

    String text = textView.getText().toString().trim();
    if (!TextUtils.isEmpty(text)) {
        transactionPhoto.replace(R.id.search_photo_container, SearchPhotoFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
        transactionCollection.replace(R.id.search_collection_container, SearchCollectionFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
        transactionUser.replace(R.id.search_user_container, SearchUserFragment.newInstance(text)).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commitAllowingStateLoss();
    }

    View view = getActivity().getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }
    return true;
}
 
开发者ID:alphater,项目名称:garras,代码行数:24,代码来源:SearchFragment.java

示例4: dispatchTouchEvent

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
    View v = getCurrentFocus();
    boolean ret = super.dispatchTouchEvent(event);

    if (v instanceof AutoCompleteTextView) {
        View currentFocus = getCurrentFocus();
        int screenCoords[] = new int[2];
        currentFocus.getLocationOnScreen(screenCoords);
        float x = event.getRawX() + currentFocus.getLeft() - screenCoords[0];
        float y = event.getRawY() + currentFocus.getTop() - screenCoords[1];

        if (event.getAction() == MotionEvent.ACTION_UP
                && (x < currentFocus.getLeft() ||
                x >= currentFocus.getRight() ||
                y < currentFocus.getTop() ||
                y > currentFocus.getBottom())) {
            InputMethodManager imm =
                    (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getWindow().getCurrentFocus().getWindowToken(), 0);
            v.clearFocus();
        }
    }
    return ret;
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:26,代码来源:PopupActivity.java

示例5: hideSoftKeybord

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
 * 隐藏软键盘
 * 
 * @param activity
 */
public static void hideSoftKeybord(Activity activity) {

       if (null == activity) {
           return;
       }
       try {
           final View v = activity.getWindow().peekDecorView();
           if (v != null && v.getWindowToken() != null) {
               InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
               imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
           }
       } catch (Exception e) {

       }
   }
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:21,代码来源:AppUtils.java

示例6: sendClick

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@OnClick(R.id.send_wish)
public void sendClick(View v) {
    String author = authorOfWish.getText().toString();
    String wish = wishText.getText().toString();
    if (canSendWish()) {
        if (!TextUtils.isEmpty(author) && !TextUtils.isEmpty(wish) && !(spinner.getSelectedItemPosition() == 0)) {
            addWishToCloud(wish, author, spinner.getSelectedItem().toString());
            Toast.makeText(this, wishSent, Toast.LENGTH_SHORT).show();
            View view = this.getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
            mLayout.setPanelState(PanelState.COLLAPSED);
        } else {
            Toast.makeText(this, fillTextView, Toast.LENGTH_SHORT).show();

        }
    } else {
        showAlertToMakeWish();
    }
}
 
开发者ID:tpakis,项目名称:Charities,代码行数:23,代码来源:ListWishesActivity.java

示例7: onKey

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
public boolean onKey(View arg0, int arg1, KeyEvent arg2) {

	switch (arg1) {
		case KeyEvent.KEYCODE_ENTER:
			InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
			searchTheWeb(mSearch.getText().toString());
			LightningView v=getCurrentWebView();
			if (v != null) {
				v.requestFocus();
			}
			return true;
		default:
			break;
	}
	return false;
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:19,代码来源:BrowserActivity.java

示例8: performAdd

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
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);
}
 
开发者ID:CactusSoft,项目名称:zabbkit-android,代码行数:13,代码来源:AddHostActivity.java

示例9: onTouch

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@Override
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) {
    if (v instanceof Spinner) {
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
                Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }
    return false;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:AutofillEditorBase.java

示例10: hideSoftKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
 * hide input method.
 */
public void hideSoftKeyboard(View view) {
    if (view == null) {
        return;
    }


    InputMethodManager inputMethodManager = (InputMethodManager) mActionBarActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager != null) {
        IBinder localIBinder = view.getWindowToken();
        if (localIBinder != null)
            inputMethodManager.hideSoftInputFromWindow(localIBinder, 0);
    }
}
 
开发者ID:Louis19910615,项目名称:youkes_browser,代码行数:17,代码来源:CCPActivityBase.java

示例11: hideKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
static public void hideKeyboard(Activity act) {
    if (act == null) return;
    if (act.getCurrentFocus() == null) {
        act.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
    } else {
        InputMethodManager imm = (InputMethodManager) act.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow((null == act.getCurrentFocus()) ? null : act.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:11,代码来源:Helper.java

示例12: hideKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
/**
 * 隐藏软键盘
 *
 * @param view 用来绑定隐藏键盘的View
 */
public static void hideKeyboard(Context context, View view) {
    if (null != context && null != view) {
        InputMethodManager imm = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
 
开发者ID:zhonglikui,项目名称:cardinalsSample,代码行数:13,代码来源:KeyboardManager.java

示例13: closeKeyBoard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
@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);
}
 
开发者ID:Light-Team,项目名称:ModPE-IDE-Source,代码行数:9,代码来源:LModActivity.java

示例14: closeKeyBoard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
private void closeKeyBoard() throws NullPointerException {
    // Central system API to the overall input method framework (IMF) architecture
    InputMethodManager inputManager =
            (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    // Base interface for a remotable object
    IBinder windowToken = getCurrentFocus().getWindowToken();

    // Hide type
    int hideType = InputMethodManager.HIDE_NOT_ALWAYS;

    // Hide the KeyBoard
    inputManager.hideSoftInputFromWindow(windowToken, hideType);
}
 
开发者ID:ujjwalagrawal17,项目名称:CodeCompilerApp,代码行数:15,代码来源:MainActivity.java

示例15: hideSoftKeyboard

import android.view.inputmethod.InputMethodManager; //导入方法依赖的package包/类
public static void hideSoftKeyboard(@NonNull AppCompatActivity activity) {
    if (activity != null && activity.getCurrentFocus() != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
        inputMethodManager.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
    }
}
 
开发者ID:anad7,项目名称:CleanArchitecture,代码行数:7,代码来源:Utils.java


注:本文中的android.view.inputmethod.InputMethodManager.hideSoftInputFromWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。