I have spinner with a style selection (I set the spinner style in strings.xml
) and it's works well if I set the style in main.xml
. But I want to know how to set the style programmatically in which the style already defined in strings.xml
.
Refer my code below
main.xml:
<Spinner
android:id="@+id/PassengersSpinner1"
android:layout_width="100dp"
android:layout_height="40dp"
android:layout_span="3"
android:layout_marginTop="6dp"
style="@style/SpinnerStyle" />
strings.xml:
<style
name="SpinnerStyle"
parent="@android:style/Widget.Spinner">
<item name="android:background">@android:drawable/btn_default</item>
</style>
Now, I want to know that how can I set this strings.xml
programmatically without main.xml
?