如何使用 C# 在 xamarin.forms 中获取所有启用的键盘
How to get all enabled keyboard in xamarin.forms with C#
美好的一天,
in android phone -> 虚拟键盘,系统在此页面列出所有启用的键盘,如何在我的 Xamarin.forms APP 中使用 C# 获取所有启用的键盘类型?
谢谢!
滚
在 Android 中,您可以使用 InputDevice
。
InputDevice
: https://developer.android.com/reference/android/view/InputDevice
您可以试试下面的代码:
int[] devicesIds = InputDevice.GetDeviceIds();
foreach (var item in devicesIds)
{
//Check the device you want
InputDevice device = InputDevice.GetDevice(item);
//device.getName must to have virtual
var s = device.Name;
var b = device.KeyboardType;
}
您可以使用 DependencyService
在 Xamarin.Forms 中调用它。
DependencyService
: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
感谢您的回复,我按照您的建议尝试了,但是返回值不是我想要的...
我又找到了一个posthere,用那个方法终于得到了我想要的东西,
这是我要分享的代码:
InputMethodManager manager = (InputMethodManager)context.GetSystemService(Context.InputMethodService);
IList<InputMethodInfo> mInputMethodProperties = manager.EnabledInputMethodList;
IEnumerator<InputMethodInfo> imi = mInputMethodProperties.GetEnumerator();
while (imi.MoveNext())
{
InputMethodInfo inputInfo = imi.Current;
var iN = inputInfo.ServiceName;
}
致以最诚挚的问候和感谢
滚动
美好的一天,
in android phone -> 虚拟键盘,系统在此页面列出所有启用的键盘,如何在我的 Xamarin.forms APP 中使用 C# 获取所有启用的键盘类型?
谢谢! 滚
在 Android 中,您可以使用 InputDevice
。
InputDevice
: https://developer.android.com/reference/android/view/InputDevice
您可以试试下面的代码:
int[] devicesIds = InputDevice.GetDeviceIds();
foreach (var item in devicesIds)
{
//Check the device you want
InputDevice device = InputDevice.GetDevice(item);
//device.getName must to have virtual
var s = device.Name;
var b = device.KeyboardType;
}
您可以使用 DependencyService
在 Xamarin.Forms 中调用它。
DependencyService
: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction
感谢您的回复,我按照您的建议尝试了,但是返回值不是我想要的...
我又找到了一个posthere,用那个方法终于得到了我想要的东西,
这是我要分享的代码:
InputMethodManager manager = (InputMethodManager)context.GetSystemService(Context.InputMethodService);
IList<InputMethodInfo> mInputMethodProperties = manager.EnabledInputMethodList;
IEnumerator<InputMethodInfo> imi = mInputMethodProperties.GetEnumerator();
while (imi.MoveNext())
{
InputMethodInfo inputInfo = imi.Current;
var iN = inputInfo.ServiceName;
}
致以最诚挚的问候和感谢
滚动