我正在使用Xamarin和C#:
我已经使用Keyboardview创建了一个自定义键盘,并希望禁用Android默认软键盘。
此活动包含大约60行EditText。
这似乎不起作用,一旦我点击另一个EditText就会出现。
Window.SetSoftInputMode (SoftInput.StateAlwaysHidden);
我的键盘视图:
protected override void OnCreate (Bundle bundle){
Window.SetSoftInputMode (SoftInput.StateAlwaysHidden);
base.OnCreate (bundle);
SetContentView (Resource.Layout.ORDER);
mKeyboardView = this.FindViewById<KeyboardView> (Resource.Id.keyboardview);
mKeyboardView.Keyboard = mKeyboard;
mKeyboardView.PreviewEnabled = false;
var keyboardListener = new MyKeyboardListener(this);
mKeyboardView.OnKeyboardActionListener = keyboardListener;
}
答案 0 :(得分:0)
您可以单击调用此方法,隐藏系统键盘,然后调用自定义键盘:
private void MakeEditable(bool isEditable, EditText et)
{
var imm = (InputMethodManager)GetSystemService(InputMethodService);
if (isEditable)
{
et.Focusable = true;
et.Enabled = true;
et.Clickable = true;
et.FocusableInTouchMode = true;
et.SetSelection(et.Text.Length);
et.RequestFocus();
imm.ShowSoftInput(et, ShowFlags.Implicit);
}
else
{
et.Focusable = false;
et.FocusableInTouchMode = false;
et.Clickable = true;
imm.HideSoftInputFromWindow(et.WindowToken, HideSoftInputFlags.None);
}
}