I am trying to programmatically create some Buttons to add them to an existing ViewGroup. This works fine, but I am not able to init the buttons with the right style.
I am aware, that it is not possible to set/change the style of view once it has been created. But all solutions I found so far say, that it should be no problem to create a view with a custom style (from a API level 11 up I think and I am using 14+):
Button button = new Button (getActivity(), null, R.style.MyButtonStyle);
The only effect is, that the button is created without any style. No background, so selector, no margin/padding just the plain text. I thought MyButtonStyle would be broken, but creating the button in XML using MyButtonStyle it no problem.
Why is this not working?