logging my app my Logcat says: WARN: ... has unresolved theme attributes! Consider using Resources.getDrawable(int, Theme) or Context.getDrawable(int).
the code which produces the warning:
if (mCards.get(position).isFavorite()) {
viewHolder.mIbStar
.setImageDrawable(mContext.getResources()
.getDrawable(R.drawable.btn_is_fav));
} else {
viewHolder.mIbStar
.setImageDrawable(mContext.getResources()
.getDrawable(R.drawable.btn_isnt_fav));
}
I searched for this log, but didn't find anything useful. How knows whats the issue? The program is stable, so no Nullpointer..
Thanks in advance
The problem is that the system can't find the associated theme to resolve these attributes values. That's why the logcat suggest you to use the Resources.getDrawable(int, Theme) method providing the theme, or to use the Context.getDrawable(int) method where the Context will use its current theme :
Return a drawable object associated with a particular resource ID and styled for the current theme.
Moreover, according to the Android official documentation : http://developer.android.com/reference/android/content/res/Resources.html#getDrawable(int)
This method was deprecated in API level 22. Use getDrawable(int, Theme) instead.
and more specifically
Note: To obtain a themed drawable, use Context.getDrawable(int) or getDrawable(int, Theme) passing the desired theme.
Consider replacing
mContext.getResources().getDrawable(int)
by
mContext.getDrawable(int)
such as proposes it the logcat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With