Is there a way to set an End Icon Click Listener on a TextInputLayout in Xamarin?
I'm trying to do something similar to what people did in this post but in Xamarin.
Is there a way to set an End Icon Click Listener on a TextInputLayout in Xamarin?
I'm trying to do something similar to what people did in this post but in Xamarin.
I did a test on my side,and it works properly on my side.
please refer to the following code:
The .xml
code:
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textInputLayout1"
android:layout_marginHorizontal="20dp"
app:helperText="Test"
app:endIconMode="custom"
app:endIconDrawable="@drawable/haixing"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/textInputEditText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
MainActivity.cs
TextInputLayout textInputLayout;
textInputLayout = FindViewById<TextInputLayout>(Resource.Id.textInputLayout1);
textInputLayout.SetEndIconOnClickListener( new MyTestClick(this));
class MyTestClick.cs
class MyTestClick : Java.Lang.Object, Android.Views.View.IOnClickListener
{
Context mContext;
public MyTestClick(Context context) {
mContext = context;
}
public void OnClick(View v)
{
Toast.MakeText(mContext, Resource.String.action_test, ToastLength.Long).Show();
}
}
Note: please update your android nuget to the latest version;