Создайте новый проект Java с помощью действия Basic View.
Добавьте фрагмент настроек.
Проверьте макет root_preferences.xml, чтобы убедиться, что он отображается в Android Studio.
Создайте собственный класс «CustomEditTextPreference», который расширяет «EditTextPreference»:
Код: Выделить всё
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.EditTextPreference;
public class CustomEditTextPreference extends EditTextPreference {
public CustomEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public CustomEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public CustomEditTextPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public CustomEditTextPreference(@NonNull Context context) {
super(context);
}
}
В Android Studio «разделенное представление» и «представление дизайна» показать пустое место с красным восклицательным знаком «Проблема с рендерингом».
класс android.preference.ListPreference нельзя привести к классу android.preference.GenericInflater$Parent (android.preference.ListPreference и android .preference.GenericInflater$Parent находятся в безымянном модуле загрузчика com.intellij.ide.plugins.cl.PluginClassLoader @3ff50027)
Указан дважды.
Android Студия Коала | 2024.1.1 Исправление 1
Сборка № AI-241.18034.62.2411.12071903, построенная 10 июля 2024 г.
Версия времени выполнения: 17.0.11+0--11852314 amd64
ВМ: OpenJDK 64- Виртуальная машина Bit Server от JetBrains s.r.o.
Windows 11.0
Понятия не имею, почему она ссылается на ListPreference, когда я расширяю EditTextPreference.
Это известная проблема? Приложение действительно работает нормально; ошибок во время выполнения нет.
Не знаю, почему это происходит. Это действительная проблема?
Подробнее здесь: https://stackoverflow.com/questions/788 ... references
Мобильная версия