在RoboBinding中有注释DependsOnStateOf。在这样的PresentationModel中使用它时:
@PresentationModel
class GreetingPresentationModel {
String firstname;
String lastname;
//getters and setters for both
@DependsOnStateOf("firstname")
public boolean isLastnameInputEnabled() {
return !TextUtils.isEmpty(firstname);
}
}这不管用。下面的绑定将始终为false,并且不会更改。
bind:enabled="{lastnameInputEnabled}"怎么了?
发布于 2015-07-06 15:32:41
查看RoboBinding AndroidMVVM示例,使用PresentationModelChangeSupport实现HasPresentationModelChangeSupport并使setter调用firePropertyChange是至关重要的
@PresentationModel
public class GreetingPresentationModel implements HasPresentationModelChangeSupport {
PresentationModelChangeSupport changeSupport;
@Override
public PresentationModelChangeSupport getPresentationModelChangeSupport() {
return changeSupport;
}
public GreetingPresentationModel() {
changeSupport = new PresentationModelChangeSupport(this);
}
// Rest of the code here
// Then change each setter, e.g.
public void setFirstname(String firstname) {
this.firstname = firstname;
changeSupport.firePropertyChange("firstname");
}
}https://stackoverflow.com/questions/31240082
复制相似问题