如何在Kotlin中处理EditText drawableRight图标的点击监听器?

问题描述 投票:-1回答:1

如何在android Kotlin中的EditText DrawableRight上处理Click事件?请找我的代码:

<EditText
            android:id="@+id/userpwd"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            app:layout_constraintStart_toStartOf="@id/guideline_left"
            app:layout_constraintEnd_toStartOf="@id/guideline_right"
            android:inputType="textWebPassword"
            android:background="@drawable/et_bg"
            android:hint="Password"
            android:textColor="@color/login_form_details_dark"
            android:padding="16dp"
            android:textColorHint="@color/login_form_details_dark"
            app:layout_constraintTop_toBottomOf="@+id/username"
            android:textCursorDrawable="@drawable/et_cursor"
            android:textColorHighlight="@color/login_form_details_dark"
            android:tooltipText="@string/app_name"
            android:layout_marginTop="16dp"
            android:drawableRight="@drawable/ic_eye"
            android:drawableTint="@color/login_form_details_dark"
            android:textColorLink="@color/login_form_details"/>
android kotlin android-vectordrawable
1个回答
0
投票

我是否知道如何用Java做到这一点你可以得到主要的想法

editText.setDrawableClickListener(new       DrawableClickListener() { public void onClick(DrawablePosition target){ switch (target){ case LEFT: //Do something here break; default: break; } } });
© www.soinside.com 2019 - 2024. All rights reserved.