小编Esl*_*med的帖子

Button.setBackground(Drawable background)抛出NoSuchMethodError

我正在实现一个简单的方法来ButtonLinearLayout编程方式添加一个.

当我调用setBackground(Drawable background)方法时,Error抛出以下内容:

java.lang.NoSuchMethodError: android.widget.Button.setBackground

我的addNewButton方法:

private void addNewButton(Integer id, String name) {

        Button b = new Button(this);
        b.setId(id);
        b.setText(name);
        b.setTextColor(color.white);
        b.setBackground(this.getResources().getDrawable(R.drawable.orange_dot));
            //llPageIndicator is the Linear Layout.
        llPageIndicator.addView(b);
}
Run Code Online (Sandbox Code Playgroud)

java android exception button

11
推荐指数
1
解决办法
6万
查看次数

标签 统计

android ×1

button ×1

exception ×1

java ×1