I have to set the background color during run time, i am using "setBackgroundColor(R.color.focusColor)" . but its nots working.
6 Answers
You can use the PorterDuff.Mode enum with its properties.
((Button)findViewById(R.id.yourButtonResId)).getBackground().setColorFilter(0xFF00FF00, PorterDuff.Mode.MULTIPLY);
Here's the result containing an unchanged default Pass button and a Submit button on which I applied the line above:

More details on this matter here.
To Google travelers, if this is a Drawable update (e.g. you are going to update your button that already have a drawable, such as button.getBackground.doStuff()) you need to use Button.invalidateSelf().
 
    
    - 1,729
- 5
- 26
- 52
You can use button.setBackgroundColor(Color.BLUE); BLUE can be replaced by the color you want if its available!
 
    
    - 5,070
- 11
- 40
- 63
its simplest way ((Button)findViewById(R.id.yourButtonResId)).setBackground(#ffffff);
 
    
    - 5
- 7
May be this question can help you a bit.
In a nutshell you have to use this.getResources().getColor(R.color.orange) in argument.
**EDIT: ** Pasted a wrong code. Edited
Try this.
 
     
     
     
    