當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。