我有以下 TextInputEditText
<com.google.android.material.textfield.TextInputLayout
android:focusableInTouchMode="true"
android:id="@+id/from_textinput"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:fontFamily="sans-serif"
android:hint="@string/from"
android:textColor="@color/colorDarkGrey"
android:textColorHint="@color/colorDarkGrey"
android:textSize="12sp"
android:textStyle="normal"
android:visibility="gone"
app:boxCornerRadiusBottomEnd="5dp"
app:boxCornerRadiusBottomStart="5dp"
app:boxCornerRadiusTopEnd="5dp"
app:boxCornerRadiusTopStart="5dp"
app:boxStrokeColor="@color/colorPrimary"
app:boxStrokeWidth="3dp"
app:layout_constraintEnd_toStartOf="@+id/to_textinput"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/doNotDisturbCheckBox">
<com.google.android.material.textfield.TextInputEditText
android:onClick="@{() -> viewModel.openFromTimePickerClicked()}"
android:focusableInTouchMode="true"
android:id="@+id/from_textedit"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:editable="false"
android:text="@{viewModel.doNotDisturbFrom}"
android:textSize="16sp" />
</com.google.android.material.textfield.TextInputLayout>
onClick 在第一次触摸时没有触发的问题,它仅在我第二次按下时才被调用
第一次点击使其成为焦点第一次点击触发点击
谁能告诉我如何从第一次开始触发点击
from_textedit.setEnabled(true);
from_textedit.setTextIsSelectable(true);
from_textedit.setFocusable(false);
from_textedit.setFocusableInTouchMode(false);
from_textedit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Edit Text is clicked");
}
});