View.setBackground抛出NoSuchMethodError错误

3
以下代码:
View inflate = inflater.inflate(R.layout.page, null);
Drawable img = getResources().getDrawable((Integer) (item.get("img")));
inflate.findViewById(R.id.page_img).setBackground(img);

产生以下错误:

java.lang.NoSuchMethodError: android.view.View.setBackground

我不知道为什么会出现这个错误。我已经尝试使用 R.drawable.img 进行 setBackground 但是仍然遇到同样的错误。

3个回答

10

2

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接