首页 > 解决方案 > 如何使用 C# 在 xamarin.forms 中获取所有启用的键盘

问题描述

再会,

在 android 手机 -> 虚拟键盘中,系统列出此页面中所有启用的键盘,如何在我的 Xamarin.forms APP 中使用 C# 获取所有启用的键盘类型?

谢谢!卷

标签: c#xamarin.formskeyboard

解决方案


在 Android 中,您可以使用InputDevice.

InputDevicehttps ://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 中调用它。

DependencyServicehttps ://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction


推荐阅读