当前位置: 首页>>代码示例>>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;未经允许,请勿转载。