Макет:
Код: Выделить всё
Код: Выделить всё
@Bindable
public StringValue getMeshChannel() {
IntegerValue meshChannel = currentDevice.getMeshChannel();
return new StringValue(String.valueOf(meshChannel.getValue()), meshChannel.isReadOnly(), meshChannel.isBasic());
}
public void setMeshChannel(String value) {
if(!String.valueOf(currentDevice.getMeshChannel().getValue()).equals(value)){
currentDevice.setMeshChannel(Integer.parseInt(value));
notifyPropertyChanged(BR.meshChannel);
}
}
Я также пробовал установить значение с помощью кода во фрагменте, например этот deviceBinding.tvMeshChannel.setText(String.valueOf(deviceViewModel.getCurrentDevice().getMeshChannel().getValue()), false);< /code>, чтобы не удалять другие значения, но всякий раз, когда я меняю значение, объект в модели представления не обновляется, поэтому я думаю, что при этом мне не хватает двусторонней привязки.
Подробнее здесь: https://stackoverflow.com/questions/787 ... two-way-da