TextInputEditText не принимает номер телефона, если локаль на хинди

Когда локаль изменилась на язык хинди, приложение не принимает ввод с клавиатуры softinput. Следующий код отлично работает для английского языка. Пожалуйста, дайте мне знать, где это пошло не так.

<com.google.android.material.textfield.TextInputLayout
                android:id="@+id/farmer_phone_number_layout"
                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/dimen_10"
                android:hint="@string/mobile_number"
                android:inputType="phone"
                app:endIconMode="clear_text"
                app:errorEnabled="true"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent"
                app:layout_constraintTop_toTopOf="parent">
                <com.google.android.material.textfield.TextInputEditText
                    android:id="@+id/farmer_phone_number_edt"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:digits="@string/input_digits"
                    android:imeOptions="actionDone"
                    android:inputType="phone"
                    android:maxLength="@integer/max_length_mobile_number_at_india"
                    android:textColor="@color/black" />
            </com.google.android.material.textfield.TextInputLayout>

Используя приведенный ниже код, я пытаюсь изменить локаль приложения.

public static Context updateResources(Context context, String countryCode) {

    Locale locale;
    locale = new Locale(countryCode.toLowerCase());
    Configuration conf = context.getResources().getConfiguration();
    conf.locale = locale;
    Locale.setDefault(locale);

    conf.setLayoutDirection(conf.locale);
    context.getResources().updateConfiguration(conf, context.getResources().getDisplayMetrics());
    return context;
}

person kashyap    schedule 08.02.2021    source источник
comment
Что содержит @string/input_digits?   -  person OMi Shah    schedule 08.02.2021
comment
‹string name=input_digits›0123456789‹/string› @OMI Shah   -  person kashyap    schedule 08.02.2021


Ответы (2)


Я предполагаю, что когда inputType является phone, он принимает только цифры '0'..'9', '+', '*' и '#', которые соответствуют стандарту ASCII, чтобы поддерживать Locale для phone, лучше удалить inputType=phone и проверить ввод пользователя для numbers в вашем собственном Locale.

person Rajan Kali    schedule 08.02.2021

Ответ Rajan.Kali: при удалении следующего заявления приложение работает нормально.

     `android:digits="@string/input_digits" `

android:inputType=phone отлично работает на языке хинди.

person kashyap    schedule 08.02.2021
comment
это то, что я собирался предложить вам удалить эту строку. - person OMi Shah; 08.02.2021