I know the Style works as it is exactly that Style that I was using before albeit in XML. A simple example of what I am doing (not working)..
LinearLayout buttonlayout = (LinearLayout) dialogLayout.findViewById(R.id.layout_menu_buttons);
Button bSettings = new Button(getActivity(), null, R.style.button_menu);
buttonlayout.addView(bSettings);
I had it working perfectly in XML, I was able to create buttons without styles no problem (this was working but didn't let me apply a style dynamically)..
Button bSettings = new Button(getActivity());
bSettings.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Complete code:
// Getting reference to the Menu layout
LinearLayout buttonlayout = (LinearLayout) dialogLayout.findViewById(R.id.layout_menu_buttons);
buttonlayout.removeAllViewsInLayout();
// Dynamically create buttons
Button bSettings = new Button(getActivity(), null, R.style.button_menu);
Button bHelp = new Button(getActivity(), null, R.style.button_menu);
Button bHistory = new Button(getActivity(), null, R.style.button_menu);
Button bAbout = new Button(getActivity(), null, R.style.button_menu);
// Adding to Layout
buttonlayout.addView(bSettings);
buttonlayout.addView(bHelp);
buttonlayout.addView(bHistory);
buttonlayout.addView(bAbout);
button_menu style..
<style name="button_menu" parent="@style/Fill.Width">
<item name="android:background">@drawable/selector_example1_button_background</item>
<item name="android:layout_margin">10dp</item>
<item name="android:padding">30dp</item>
</style>
Note: I have checked using the DDMS Dump View and found that all of the buttons are there, they all have the correct text etc. I just can't see them, they don't seem to be actually using any of the properties that are included in the style.
I have also tried setting the LayoutParams again after setting the style which made no difference.
Bit confused by this..
Any ideas?