android 中如何获取系统中安装的所有输入法并以列表显示?
发布网友
发布时间:2022-04-30 02:07
我来回答
共3个回答
热心网友
时间:2023-10-03 05:34
private void onCreateIMM() {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethodProperties = imm.getInputMethodList();
mLastInputMethodId = Settings.Secure.getString(getContentResolver(),
Settings.Secure.DEFAULT_INPUT_METHOD);
PreferenceGroup textCategory = (PreferenceGroup) findPreference("text_category");
int N = (mInputMethodProperties == null ? 0 : mInputMethodProperties
.size());
for (int i = 0; i < N; ++i) {
InputMethodInfo property = mInputMethodProperties.get(i);
String prefKey = property.getId();
CharSequence label = property.loadLabel(getPackageManager());
boolean systemIME = isSystemIme(property);
// Add a check box.
// Don't show the toggle if it's the only keyboard in the system, or it's a system IME.
if (mHaveHardKeyboard || (N > 1 && !systemIME)) {
CheckBoxPreference chkbxPref = new CheckBoxPreference(this);
chkbxPref.setKey(prefKey);
chkbxPref.setTitle(label);
textCategory.addPreference(chkbxPref);
mCheckboxes.add(chkbxPref);
}
// If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(this, null);
String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label);
if (N == 1) {
prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
} else {
CharSequence settingsLabel = getResources().getString(
R.string.input_methods_settings_label_format, label);
prefScreen.setSummary(settingsLabel);
}
textCategory.addPreference(prefScreen);
}
}
}
热心网友
时间:2023-10-03 05:35
首先对如入法进行判断输入法是不是出于激活状态,也就是 是不是显示着。
显示虚拟键盘
隐藏虚拟键盘
输入法软键盘进行强制显示或者关闭系统键盘
热心网友
时间:2023-10-03 05:35
您是2.2的系统吗