本文介绍了如何在Xamarin.Forms上保留键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Entry.unfocus/Entry.completed隐藏键盘,如何取消它?
Entry.unfocus/Entry.completed hides keyboard, how to cancel it?
我有一个包含一些条目的页面,当我按键盘上的Enter键时,我希望键盘不隐藏.如何使用PCL项目(Android e iOS)做到这一点?
I have a page with some entries and when I press keyboard enter key, I want the keyboard not hides. How to do that with PCL project (Android e iOS)?
推荐答案
只是指出了另一种适用于Android的解决方案.如果要始终保持特定编辑器渲染器的键盘可见,则需要在MainActivity类中重写以下方法:
Just to point out another solution for Android. In case you want to keep always visible the keyboard for a specific Editor Renderer, you need to override the following methods in the MainActivity class:
private bool _lieAboutCurrentFocus;
public override bool DispatchTouchEvent(MotionEvent ev)
{
var focused = CurrentFocus;
bool customEntryRendererFocused = focused != null && focused.Parent is YourCustomEditorRenderer;
_lieAboutCurrentFocus = customEntryRendererFocused;
var result = base.DispatchTouchEvent(ev);
_lieAboutCurrentFocus = false;
return result;
}
public override Android.Views.View CurrentFocus
{
get
{
if (_lieAboutCurrentFocus)
{
return null;
}
return base.CurrentFocus;
}
}
您可以找到更详细的解释此处
You can find a more detail explanation here
希望这会有所帮助.
致谢
这篇关于如何在Xamarin.Forms上保留键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!