[英]Refresh star color from ratingbar in ListView
I have a problem when i try to change my stars color from RatingBar into a ListView Adapter and i don´t understand why is not working because outside the listview everything seems to work properly with same code. 当我尝试将我的星星颜色从RatingBar更改为ListView Adapter时,我遇到问题,我不明白为什么不起作用,因为在ListView之外,所有内容似乎都可以使用相同的代码正常工作。
My code for changing star color is: 我更改星色的代码是:
DrawableCompat.setTint(holder.ratingBar.getProgressDrawable(), pContext.getResources().getColor(R.color.orange));
Anyone encounter this problem? 有人遇到这个问题吗?
Update : I fixed my problem with this code 更新 :我解决了此代码的问题
LayerDrawable layerDrawable = (LayerDrawable) holder.ratingBar.getProgressDrawable();
DrawableCompat.setTint(DrawableCompat.wrap(layerDrawable.getDrawable(0)), Color.RED); // Empty star
DrawableCompat.setTint(DrawableCompat.wrap(layerDrawable.getDrawable(1)), Color.BLUE); // Partial star
DrawableCompat.setTint(DrawableCompat.wrap(layerDrawable.getDrawable(2)), Color.BLUE); // Full star
I believe you are encounter a similar problem as this, seems to be a bug in the support library. 我相信您遇到的与此类似的问题,似乎是支持库中的错误。
https://code.google.com/p/android/issues/detail?id=172067 https://code.google.com/p/android/issues/detail?id=172067
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.