Android MVVM Java, привязка данных для AppCompatImageViewJAVA

Программисты JAVA общаются здесь
Ответить
Anonymous
 Android MVVM Java, привязка данных для AppCompatImageView

Сообщение Anonymous »

На мой взгляд, у меня есть AppCompactImageView, мне нужно установить srcCompact из модели представления.

Код: Выделить всё

 app:srcCompat="@{viewModel.statusIcon}" />
Под моей моделью просмотра

Код: Выделить всё

public class MnpRequestStatusViewModel extends BaseViewModel {

//#region variable to hold user input MSIDN.
private MutableLiveData msidn = new MutableLiveData();
public MutableLiveData getMsidn() {
return msidn;
}
//#endregion
//#region variable to hold brand
private Brand brand;
public Brand getBrand() {
return brand;
}
public void setBrand(Brand brand) {
this.brand = brand;
}
//#endregion
//#region variable to hold message box visibility
private final MutableLiveData messageBoxVisibility;
public MutableLiveData getMessageBoxVisibility() {
return messageBoxVisibility;
}
//#endregion
//#region variable to hold status icon.
private final MutableLiveData statusIcon;
public MutableLiveData getStatusIcon() {
return statusIcon;
}
public void setStatusIcon(int drawableResId) {
statusIcon.setValue(drawableResId);
}
//#endregion
//#region variable to hold status desc
private final MutableLiveData statusDesc;
public MutableLiveData getStatusDesc() {
return statusDesc;
}
//#endregion
//#region variable to hold error message
private final MutableLiveData errorMsg;
public MutableLiveData getErrorMsg() {
return errorMsg;
}
//#endregion
//#endregion
//#region variable to hold continue button visibility
private final MutableLiveData showContinueButton;

public MutableLiveData  getShowContinueButton() {
return showContinueButton;
}
//#endregion
public MnpRequestStatusViewModel(@NonNull Application application) {
super(application);
messageBoxVisibility = new MutableLiveData();
msidn = new MutableLiveData();
statusIcon = new MutableLiveData(R.drawable.ic_progress_24);
errorMsg = new MutableLiveData();
statusDesc = new MutableLiveData();

}
}
При сборке приложения возникает ошибка «ошибка: невозможно найти символ».
import com.example.android_test.databinding.FragmentMnpRequestStatusBindingImpl;
Необходимо найти решение, как привязать рисуемый ресурс к AppCompatImageView с помощью привязки данных MVVM.

Подробнее здесь: https://stackoverflow.com/questions/788 ... timageview
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «JAVA»