Android – view.setbackground throws nosuchmethoderror
•
Android
See English answer > setbackground vs setbackgrounddrawable (Android) 12 following codes:
View inflate = inflater.inflate(R.layout.page, null);
Drawable img = getResources().getDrawable((Integer) (item.get("img")));
inflate.findViewById(R.id.page_img).setBackground(img);
The following error occurred:
java.lang.NoSuchMethodError:android.view.View.setBackground
I don't know why. I've tried setbackground with r.drawable.img, but I got the same error
resolvent:
This method was introduced in API level 16, and you are likely to run on an earlier version:
http://developer.android.com/reference/android/view/View.html#setBackground (android.graphics.drawable.Drawable)
Use setbackgrounddrawable()
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码