TB1*_*B13 1 android onclicklistener android-textinputlayout android-textinputedittext material-components-android
如何单击每个 TextInputEditText 的 drawableRight 编辑图像?我想单击编辑图标,然后启用编辑每个字段。我怎样才能做到这一点?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--First name-->
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="@dimen/_64dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etFirstName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:drawableRight="@drawable/icon_edit"
android:hint="@string/label_fname"
android:inputType="textCapWords" />
</com.google.android.material.textfield.TextInputLayout>
<!--Middle name-->
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/activity_registration_tiMiddleName"
android:layout_width="match_parent"
android:layout_height="@dimen/_64dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etMiddleName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:drawableRight="@drawable/icon_edit"
android:hint="@string/label_mname"
android:inputType="textCapWords"/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
那么如何使用 drawbleRight 单独编辑每个字段。请帮忙。
不要android:drawableRight在TextInputEditText.
用:
<com.google.android.material.textfield.TextInputLayout
...
app:endIconMode="custom"
app:endIconDrawable="@drawable/..."
Run Code Online (Sandbox Code Playgroud)
和:
textInputLayout.setEndIconOnClickListener {
// Respond to end icon presses
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
288 次 |
| 最近记录: |