AccountHeader headerResult = new AccountHeaderBuilder()
.withActivity(this)
.withHeaderBackground(Color.parseColor(mPrefs.getString("theme_color",getResources().getString(R.string.default_color)))
.withSelectionListEnabledForSingleProfile(false)
... and so on
但是当设置头部背景时,我遇到了错误消息“期望一个颜色资源id(R.color.)但接收到了RGB整数”,无法从首选项中读取背景颜色。日志上给出错误:"android.content.res.Resources$NotFoundException: Resource ID #0x2e60e8"
withHeaderBackground
需要资源ID(例如 R.id.someColor),但你传递的是HEX代码。这就是为什么会出现该错误。你是如何在偏好设置中保存颜色的? - V-rund Puro-hit