TextInputEditText에서 쉼표 문자를 비활성화하려고 합니다. XML 파일에 두 개의 매개변수(숫자 및 입력 유형)를 추가했습니다. 하지만 여전히 키보드에서 쉼표를 입력할 수 있습니다.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/price"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_10sdp"
android:layout_marginStart="@dimen/_20sdp"
android:layout_marginEnd="@dimen/_20sdp"
app:counterEnabled="true"
app:counterMaxLength="7"
app:errorEnabled="true"
app:hintTextColor="@android:color/holo_orange_dark"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/section_text"> <com.google.android.material.textfield.TextInputEditText
android:id="@+id/price_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:digits="0123456789."
android:hint="@string/price_hint"
android:maxLength="7"
android:singleLine="true" /> </com.google.android.material.textfield.TextInputLayout>
- 답변 # 1
이 code는