one control with different background color in different styles in android -
i have 2 activity: activity1 , activity2
theme of activity1 blue , other 1 orange
now have xml layout (sort_items.xml) inflated in these activities
i want layout's background color blue when open activity1 , orange when open activity2.
i created 2 style in styles.xml:
<style name="appthemeorange" parent="@style/theme.appcompat.light.darkactionbar"> <item name="actionbarstyle">@style/myactionbarorange</item> </style> <style name="appthemeblue" parent="@style/theme.appcompat.light.darkactionbar"> <item name="actionbarstyle">@style/myactionbarblue</item> </style>
and these themes attributed activitoes in manifest.xml
also 2 color in colors.xml
<color name="orange">#ffa726</color> <color name="blue">#119eff</color>
and sort_items.xml
<linearlayout android:layout_width="fill_parent" android:layout_height="50dip" android:background="???" android:id="@+id/layout1"> ... </linearlayout>
now how set layout1 (in sort_items.xml) background color change automatically in each activity?
thanks.
i'm not sure understand, did tried
mlinearlayout.setbackgroundcolor(mcontext.getresources().getcolor(r.color.orange));
Comments
Post a Comment