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


Java InputMethodManager類代碼示例

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


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

示例1: onEditorAction

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (EditorInfo.IME_ACTION_DONE == actionId) {
        if (mEditText.getText().toString().isEmpty())
        {
            SuperToast toast = chatSDKUiHelper.getAlertToast();
            toast.setGravity(Gravity.TOP, 0, 0);
            toast.setText("Please enter chat name");
            toast.show();
            return true;
        }

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

        // Return input text to activity
        listener.onFinished(mEditText.getText().toString());
        this.dismiss();
        return true;
    }
    return false;
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:24,代碼來源:DialogUtils.java

示例2: run

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
@Override
public void run() {
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(w, h + HEIGHT_PADDING);
    params.leftMargin = x;
    params.topMargin = y;

    if (mTextEdit == null) {
        mTextEdit = new DummyEdit(getContext());

        mLayout.addView(mTextEdit, params);
    } else {
        mTextEdit.setLayoutParams(params);
    }

    mTextEdit.setVisibility(View.VISIBLE);
    mTextEdit.requestFocus();

    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mTextEdit, 0);

    mScreenKeyboardShown = true;
}
 
開發者ID:suikki,項目名稱:simpleSDL,代碼行數:23,代碼來源:SDLActivity.java

示例3: hideKeyboard

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
public static void hideKeyboard(@NonNull Activity activity) {
    View view = activity.getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }
}
 
開發者ID:bignerdranch,項目名稱:Typesetter,代碼行數:8,代碼來源:AndroidUtils.java

示例4: onFocusChanged

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
@Override
protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) {
    super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
    if (mFocusAnim != null) {
        mFocusAnim.end();
    }
    if (gainFocus) {
        mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, (float) (getWidth() - 2 * mRoundRadius));
        input.showSoftInput(this, InputMethodManager.SHOW_FORCED);
    } else {
        mFocusAnim = ObjectAnimator.ofFloat(this, "FocusLine", mFocusLineLength, 0);
        input.hideSoftInputFromInputMethod(this.getWindowToken(), 0);
    }
    mFocusAnim.setDuration(1000).setInterpolator(new OvershootInterpolator());
    mFocusAnim.start();
}
 
開發者ID:paradoxie,項目名稱:DizzyPassword,代碼行數:17,代碼來源:PswInputView.java

示例5: hideKeyboard

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
/**
 * Hides the soft keyboard from screen
 *
 * @param view Usually the EditText, but in dynamically  layouts you should pass the layout
 * instead of the EditText
 * @return true, if keyboard has been hidden, otherwise false (i.e. the keyboard was not displayed
 * on the screen or no Softkeyboard because device has hardware keyboard)
 */
public static boolean hideKeyboard(View view) {

  if (view == null) {
    throw new NullPointerException("View is null!");
  }

  try {
    InputMethodManager imm =
        (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

    if (imm == null) {
      return false;
    }

    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
  } catch (Exception e) {
    return false;
  }

  return true;
}
 
開發者ID:VK2012,項目名稱:AppCommonFrame,代碼行數:30,代碼來源:KeyboardUtils.java

示例6: showSoftKeyboard

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
public void showSoftKeyboard() {
	if (isKeyboardOpen()) return;

	if (ui.emojiDrawer.isShowing()) {
		postOnKeyboardOpen(new Runnable() {
			@Override
			public void run() {
				hideEmojiDrawer();
			}
		});
	}
	ui.editText.post(new Runnable() {
		@Override
		public void run() {
			ui.editText.requestFocus();
			InputMethodManager imm =
					(InputMethodManager) getContext()
							.getSystemService(INPUT_METHOD_SERVICE);
			imm.showSoftInput(ui.editText, SHOW_IMPLICIT);
		}
	});
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:23,代碼來源:TextInputView.java

示例7: onCreate

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
/**
 * Main initialization of the input method component.  Be sure to call
 * to super class.
 */
@Override public void onCreate() {
    super.onCreate();
    mInputMethodManager = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
    mWordSeparators = getResources().getString(R.string.word_separators);
    mSuggestions = EMPTY_LIST;
    mQuranSuggestions = EMPTY_MLIST;
    mSavedPreSpaces = 0;

    try {
        mQuranSearch = new QuranSearch(this);
    } catch (IOException |SecurityException e) {
        mQuranSearch = null;
        Toast.makeText(this, "Quran Search disabled, File not found!", Toast.LENGTH_LONG).show();
        // TODO disable/gray the Moshaf/shift key & disable/grey Prefs
        if (DEBUG) e.printStackTrace();
    }

    if (mQuranSearch != null) {
        PreferenceManager.setDefaultValues(this, R.xml.ime_preferences, false);

        setUthmaniTypeFace(Typeface.createFromAsset(getAssets(), "UthmanicHafs.otf"));
    }
}
 
開發者ID:cdjalel,項目名稱:QuranKeyboard,代碼行數:28,代碼來源:QuranKeyboardIME.java

示例8: setCancelAction

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
private void setCancelAction(Button cancelButton, final EditText dateEditText,
                             final EditText timeEditText, final TextInputLayout... textInputLayouts) {
    cancelButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (TextInputLayout textInputLayout : textInputLayouts) {
                textInputLayout.getEditText().setText("");
                textInputLayout.clearFocus();
                // Hide the keyboard
                InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(textInputLayout.getEditText().getWindowToken(), 0);
            }
            dateEditText.setText("");
            timeEditText.setText("");
        }
    });
}
 
開發者ID:kflauri2312lffds,項目名稱:Android_watch_magpie,代碼行數:18,代碼來源:AddValueFragment.java

示例9: setKeypadVisibility

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
public static void setKeypadVisibility(Context context, EditText inputNote, int visibility) {
    InputMethodManager imm = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    switch (visibility) {
        case View.VISIBLE:
            // 開啟鍵盤
            imm.showSoftInput(inputNote, InputMethodManager.SHOW_IMPLICIT);
            break;
        case View.GONE:
        case View.INVISIBLE:
            // 關閉鍵盤
            imm.hideSoftInputFromWindow(inputNote.getWindowToken(), 0);
            break;
    } /* end of switch */
}
 
開發者ID:Welloculus,項目名稱:MobileAppForPatient,代碼行數:17,代碼來源:GuiUtils.java

示例10: showSoftInputFromWindow

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
/**
 * EditText獲取焦點並顯示軟鍵盤
 */
public void showSoftInputFromWindow(EditText editText) {
    //添加文字edittext彈出軟鍵盤
    editText.setFocusable(true);
    editText.setFocusableInTouchMode(true);
    editText.requestFocus();
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            InputMethodManager imm = (InputMethodManager) PostActivity.this
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
        }

    }, 100);//這裏的時間大概是自己測試的
}
 
開發者ID:gitxuyulin,項目名稱:EditorImageAndText,代碼行數:21,代碼來源:PostActivity.java

示例11: showKeyboard

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
public void showKeyboard(View view) {
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1 && view.hasFocus()) {
        view.clearFocus();
    }
    view.requestFocus();
    InputMethodManager imm = (InputMethodManager) view.getContext()
        .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.showSoftInput(view, 0);
    }
}
 
開發者ID:nichbar,項目名稱:Aequorea,代碼行數:12,代碼來源:MaterialSearchView.java

示例12: switchToNextInputMethodAndSubtype

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
private boolean switchToNextInputMethodAndSubtype(final IBinder token) {
    final InputMethodManager imm = mImmWrapper.mImm;
    final List<InputMethodInfo> enabledImis = imm.getEnabledInputMethodList();
    final int currentIndex = getImiIndexInList(getInputMethodInfoOfThisIme(), enabledImis);
    if (currentIndex == INDEX_NOT_FOUND) {
        Log.w(TAG, "Can't find current IME in enabled IMEs: IME package="
                + getInputMethodInfoOfThisIme().getPackageName());
        return false;
    }
    final InputMethodInfo nextImi = getNextNonAuxiliaryIme(currentIndex, enabledImis);
    final List<InputMethodSubtype> enabledSubtypes = getEnabledInputMethodSubtypeList(nextImi,
            true /* allowsImplicitlySelectedSubtypes */);
    if (enabledSubtypes.isEmpty()) {
        // The next IME has no subtype.
        imm.setInputMethod(token, nextImi.getId());
        return true;
    }
    final InputMethodSubtype firstSubtype = enabledSubtypes.get(0);
    imm.setInputMethodAndSubtype(token, nextImi.getId(), firstSubtype);
    return true;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:22,代碼來源:RichInputMethodManager.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: HideSoftInput

import android.view.inputmethod.InputMethodManager; //導入依賴的package包/類
private void HideSoftInput(IBinder token) {
    if (token != null) {
        InputMethodManager manager = (InputMethodManager) activity.getSystemService(activity.INPUT_METHOD_SERVICE);
        manager.hideSoftInputFromWindow(token,
                InputMethodManager.HIDE_NOT_ALWAYS);
    }
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:8,代碼來源:IjkPlayer.java

示例15: 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


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