如何声明自定义Entry,详见以下内容
https://learn.microsoft.com/zh-cn/xamarin/xamarin-forms/app-fundamentals/custom-renderer/entry
C#代码
public class MyEntry : Entry
{
}
Android中代码
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Text;
using Android.Views;
using Android.Views.InputMethods;
using Android.Widget;
using App5;
using App5.Droid;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace App5.Droid
{
public class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
EditText editText = Control;
editText.InputType = Android.Text.InputTypes.Null;
}
}
}
}
Xaml 中代码
要先引用名称空间
xmlns:local=“clr-namespace:App5”
<local:MyEntry x:Name=“myentry” Placeholder=“click me !but I can’t load keyboard 😃”/>