as far as I understand your problem is setting the Color of the button programatically.
You could for example do it like this:
macase.setBackgroundColor(Color.BLUE);
题
I have created a lot of buttons, in the java code, which represent some houses(for example). I want to create another button which is called "selection multiple". When i click on this button(selection multiple), all the others buttons(the houses) will change style or color when I click on them. The problems is that I create the buttons ( house ) in the java code so i don't find how to change their style when I click on them /:
Button macase = new Button (this);
macase.setText("o"+Numcase);
tr.addView(macase);
解决方案 2
as far as I understand your problem is setting the Color of the button programatically.
You could for example do it like this:
macase.setBackgroundColor(Color.BLUE);
其他提示
Once you have a reference to your button object, you can change it's image or background (for example) with these functions.
macase.setImageResource(R.drawable.myicon);
macase.setBackgroundResource(R.drawable.mycustomButton);
In the second case, mycustomButton is an XML file with the custom style you want to apply