我想檢查來自服務器的布爾值。如果布爾值爲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]。你有什麼是三個代碼 –