1

I want to set button background from Java code I have this code

    public void Save(View sender){
    Button btn=(Button)sender;
    btn.setBackground(R.drawable.mybuttonbackground);

but this doesn't work and isn't compiled.

So How to set button background from Java Code

thank you for your answers.

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
PcAF
  • 1,975
  • 12
  • 20

1 Answers1

2

Try this instead

btn.setBackgroundResource(R.drawable.mybuttonbackground);
Bidhan
  • 10,607
  • 3
  • 39
  • 50