При обновлении любой из следующих зависимостей до последней доступной на данный момент версии:
Код: Выделить всё
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.core:core:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
Код: Выделить всё
public class PageViewModel extends ViewModel {
private final MutableLiveData mIndex = new MutableLiveData();
private final LiveData mText = Transformations.map(mIndex, new Function() {
@Override
public String apply(Integer input) {
String text = "";
String prefixurl = "some text";
if (input == 1) {
text = System.lineSeparator() + System.lineSeparator() + "some text" +
System.lineSeparator() + "some text" +
System.lineSeparator() + "some text";
} else if (input == 2) {
text = System.lineSeparator() + System.lineSeparator() + "some text" +
System.lineSeparator() + "some text" +
System.lineSeparator() + "some text";
} else if (input == 3) {
text = System.lineSeparator() + System.lineSeparator() + "some text" +
System.lineSeparator() + "some text" +
System.lineSeparator() + "some text" +
System.lineSeparator() + "some text";
}
return "some text: " + input + text + System.lineSeparator() + System.lineSeparator() + "some text.";
}
});
public void setIndex(int index) {
mIndex.setValue(index);
}
public LiveData getText() {
return mText;
}
Код: Выделить всё
private final LiveData mText = Transformations.map(mIndex, new Function() {
^
required: LiveData,Function1
found: MutableLiveData,
reason: cannot infer type-variable(s) X,Y
(argument mismatch; cannot be converted to Function1)
where X,Y are type-variables:
X extends Object declared in method map(LiveData,Function1)
Y extends Object declared in method map(LiveData,Function1)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Сообщите мне, что чего-то не хватает или что-то необходимо информация, чтобы понять/ответить на вопрос.
Подробнее здесь: https://stackoverflow.com/questions/788 ... pendencies
Мобильная версия