Reputation: 3871
I have this piece of code, which is expected to change the color of the button to BLUE, but it does not have any effect. The code goes into this if statement but does not change the color. On the other hand , the same statement when used earlier does actually change the color of the button. Why is this so?
if(t.equals("a"))
{
Toast toast5=Toast.makeText(getApplicationContext(),"a found", Toast.LENGTH_SHORT);
toast5.show();
btn6.getBackground().setColorFilter(Color.BLUE, PorterDuff.Mode.MULTIPLY);
}
Upvotes: 0
Views: 238
Reputation: 48592
// Get Handle for the Tab buttons
Button btnTab1 = (Button) findViewById(R.id.button_tab1);
Button btnTab2 = (Button) findViewById(R.id.button_tab1);
// set the colors correctly
btnTab1.setBackgroundResource(R.color.lightblue);
btnTab2.setBackgroundResource(R.color.darkblue);
Upvotes: 3
Reputation: 3796
You implement for this code,
btn6.setBackgroundColor(Color.colorChoose);
btn6.setBackgroundDrawable(Drawable drawable);
btn6.setBackgroundResource(int resid);
Upvotes: -1