當前位置: 首頁>>代碼示例>>Java>>正文


Java InputMethodManager.isActive方法代碼示例

本文整理匯總了Java中android.view.inputmethod.InputMethodManager.isActive方法的典型用法代碼示例。如果您正苦於以下問題:Java InputMethodManager.isActive方法的具體用法?Java InputMethodManager.isActive怎麽用?Java InputMethodManager.isActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.inputmethod.InputMethodManager的用法示例。


在下文中一共展示了InputMethodManager.isActive方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeInputKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * 關閉軟鍵盤
 * @param activity
 */
public static void closeInputKeyboard(Activity activity) {
    if(activity != null) {
        InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if(inputMethodManager != null) {
            boolean active = inputMethodManager.isActive();
            if (active) {
                View currentFocus = activity.getCurrentFocus();
                if (currentFocus != null) {
                    IBinder windowToken = currentFocus.getWindowToken();
                    if (windowToken != null) {
                        inputMethodManager.hideSoftInputFromWindow(
                                windowToken,
                                InputMethodManager.HIDE_NOT_ALWAYS);
                    }
                }
            }
        }
    }
}
 
開發者ID:Sugarya,項目名稱:Closet,代碼行數:24,代碼來源:KeyboardUtils.java

示例2: onKey

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    pressSearch = (keyCode == KeyEvent.KEYCODE_ENTER);
    if (pressSearch && listener != null) {
        /*隱藏軟鍵盤*/
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
        }
        if (event.getAction() == KeyEvent.ACTION_UP) {
            pressSearch = false;
            listener.onSearchClick(v);
        }
    }
    return false;
}
 
開發者ID:6ag,項目名稱:LiuAGeAndroid,代碼行數:17,代碼來源:SearchEditText.java

示例3: hintKbTwo

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
private void hintKbTwo() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive() && getCurrentFocus() != null) {
        if (getCurrentFocus().getWindowToken() != null) {
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:9,代碼來源:MainActivity.java

示例4: hideSoftKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * 隱藏軟鍵盤
 *
 * @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);
}
 
開發者ID:Wan7451,項目名稱:mvparms,代碼行數:16,代碼來源:DeviceUtils.java

示例5: hideImm

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * Hide the input method like soft keyboard, etc... when they are active.
 */
private void hideImm() {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(fab.getWindowToken(), 0);
    }
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:10,代碼來源:AddPackageFragment.java

示例6: hideImm

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * Hide the input method like soft keyboard, etc... when they are active.
 */
private void hideImm() {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
    }
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:10,代碼來源:SearchFragment.java

示例7: HideKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
public static void HideKeyboard(View v) {
    InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);

    }
}
 
開發者ID:zeng3234,項目名稱:GrowingProject,代碼行數:8,代碼來源:KeyboardUtils.java

示例8: onTouchEvent

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent event) {
  final boolean ret = super.onTouchEvent(event);
  // Must be done after super.onTouchEvent()
  final InputMethodManager imm =
      ((InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE));
  if (imm != null && imm.isActive(this)) {
    imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
  }
  return ret;
}
 
開發者ID:dialogs,項目名稱:android-dialer,代碼行數:12,代碼來源:DigitsEditText.java

示例9: hideKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
public static void hideKeyboard(View view) {
    if (view == null) {
        return;
    }
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (!imm.isActive()) {
            return;
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:15,代碼來源:AndroidUtilities.java

示例10: isKeyboardShowed

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
public static boolean isKeyboardShowed(View view) {
    if (view == null) {
        return false;
    }
    try {
        InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        return inputManager.isActive(view);
    } catch (Exception e) {
        FileLog.e("tmessages", e);
    }
    return false;
}
 
開發者ID:pooyafaroka,項目名稱:PlusGram,代碼行數:13,代碼來源:AndroidUtilities.java

示例11: hideSoftInput

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * Hides the soft input if it is active for the input text.
 */
private void hideSoftInput() {
    InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); // FIXME? InputMethodManager.peekInstance();
    if (inputMethodManager != null && inputMethodManager.isActive(mInputText)) {
        inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
        if (mHasSelectorWheel) {
            mInputText.setVisibility(View.INVISIBLE);
        }
    }
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:13,代碼來源:NumberPicker.java

示例12: hideKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * 隱藏軟鍵盤
 * @param activity
 */
public static void hideKeyboard(Activity activity) {
    if (activity != null) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isActive()) {
            imm.hideSoftInputFromWindow(activity.getCurrentFocus().getWindowToken(), 0);
        }
    }
}
 
開發者ID:zqHero,項目名稱:rongyunDemo,代碼行數:13,代碼來源:CommonUtils.java

示例13: initViews

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
public void initViews() {
    /* 隱藏軟鍵盤 */
    InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        View focusView = ((Activity) mContext).getCurrentFocus();
        if (focusView != null)
            imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
    }
    mAttrs = readAttribute();// 獲取主題屬性
    mView = createView();
    mBg.startAnimation(createAlphaInAnimation());
    mPanel.startAnimation(createTranslationInAnimation());
}
 
開發者ID:StickyTolt,項目名稱:ForeverLibrary,代碼行數:14,代碼來源:ActionSheet.java

示例14: applyKeyboardShowHide

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
private void applyKeyboardShowHide(boolean autofocus) {
    final InputMethodManager imm = ((InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE));
    if (imm != null) {
        if(isDigit) {
            if(imm.isActive(this)) {
                imm.hideSoftInputFromWindow(getApplicationWindowToken(), 0);
            }
        }else if(autofocus) {
            imm.showSoftInput(this, 0);
        }
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:14,代碼來源:DigitsEditText.java

示例15: toggleKeyboard

import android.view.inputmethod.InputMethodManager; //導入方法依賴的package包/類
/**
 * 切換鍵盤的顯示與隱藏
 *
 * @param activity
 */
public static void toggleKeyboard(Activity activity) {
    InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
        inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
開發者ID:zhudongya123,項目名稱:WechatChatroomHelper,代碼行數:12,代碼來源:BGAKeyboardUtil.java


注:本文中的android.view.inputmethod.InputMethodManager.isActive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。