Bouton.setBackground(Drawable arrière-plan) throws NoSuchMethodError

Je me suis mise en œuvre d'une méthode simple pour ajouter un Button à un LinearLayout par programmation.

Quand j'invoque le setBackground(Drawable arrière-plan), la méthode suivante Error est jeté:

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

Mon addNewButton méthode:

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);
}

OriginalL'auteur Eslam Yousef Mohammed | 2013-09-01