Where is ReturnType in RadEntry?
Environment
Product Version | R3 2020 |
Product | Entry for Xamarin |
Description
RadEntry does not provide ReturnType property as the Xamarin.Forms Entry ReturnType, still, there is an easy way to implement it by creating custom native renderers on both Android and iOS, taking the native EditText and UITextField controls and setting their corresponding properties.
- For Android override OnElementChanged event and apply
ImeOptions
of the native EditText control:
using Android.Content;
using Android.Text;
using Android.Widget;
using EntryExample.Droid;
using Telerik.XamarinForms.Input;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(RadEntry), typeof(CustomEntryRenderer))]
namespace EntryExample.Droid
{
public class CustomEntryRenderer : Telerik.XamarinForms.InputRenderer.Android.EntryRenderer
{
public CustomEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<RadEntry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
((EditText)Control).ImeOptions = global::Android.Views.InputMethods.ImeAction.Next;
}
}
}
}
- For iOS override again OnElementChanged and apply
ReturnKeyType
to the native UITextField control:
using EntryExample.iOS;
using Telerik.XamarinForms.Input;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(RadEntry), typeof(CustomEntryRenderer))]
namespace EntryExample.iOS
{
public class CustomEntryRenderer: Telerik.XamarinForms.InputRenderer.iOS.EntryRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<RadEntry> e)
{
base.OnElementChanged(e);
((UITextField)Control).ReturnKeyType = UIReturnKeyType.Next;
}
}
}
Here is the result on Android and iOS: