编译器抛出与方法关联的构建异常@Bindable 必须遵循与标记为@Bindable 的getter 相关的JavaBeans 约定,该getter 接受一个参数(phototag)并根据该参数值返回特定字段的值:
private boolean operationPhotoSaved;
private boolean material1PhotoSaved;
private boolean material2PhotoSaved;
private boolean material3PhotoSaved;
private boolean material4PhotoSaved;
private boolean material5PhotoSaved;
@Bindable
public boolean isPhotoSaved (PhotoTag photoTag){
boolean isSaved = false;
switch (photoTag) {
case OPERATIONPHOTO:
isSaved = this.operationPhotoSaved;
break;
case MATERIAL1PHOTO:
isSaved = this.material1PhotoSaved;
break;
case MATERIAL2PHOTO:
isSaved = this.material2PhotoSaved;
break;
case MATERIAL3PHOTO:
isSaved = this.material3PhotoSaved;
break;
case MATERIAL4PHOTO:
isSaved = this.material4PhotoSaved;
break;
case MATERIAL5PHOTO:
isSaved = this.material5PhotoSaved;
break;
}
return isSaved;
}
似乎这在 Android 数据绑定中是不允许的?