如何在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"/>
我是否知道如何用Java做到这一点你可以得到主要的想法
editText.setDrawableClickListener(new DrawableClickListener() { public void onClick(DrawablePosition target){ switch (target){ case LEFT: //Do something here break; default: break; } } });