我想检查来自服务器的布尔值。如果布尔值为true,我想禁用按钮单击。否则,可以点击按钮。我使用Retrofit将所有数据从服务器添加到其余。禁用基于Retrofit响应的按钮
@ API
"bookmarked": true
@餐厅对象
private boolean bookmarked;
public boolean isBookmarked() {
return bookmarked;
}
public void setBookmarked(boolean bookmarked) {
this.bookmarked = bookmarked;
}
@的onCreate()
Restaurant rest;
Button btn;
@Override
public void success(Restaurant restaurant, Response response) {
rest = restaurant;
}
if (rest.isBookmarked()) {
btn.setOnClickListener(null);
}
请参阅关于[mcve]。你有什么是三个代码 –