I defined two attributes for button style like
<!-- attrs.xml-->
<declare-styleable name="MyCustomButton">
<attr name="rectangleCustomButtonStatus1" format="reference" />
<attr name="rectangleCustomButtonStatus2" format="reference" />
</declare-styleable>
<!-- styles.xml -->
<style name="AppTheme">
<item name="rectangleCustomButtonStatus1">@style/GoldButtonStyle</item>
<item name="rectangleCustomButtonStatus2">@style/WhiteButtonStyle</item>
....
</style>
GoldButtonStyle and WhiteButtonStyle i defined in style.xml itself.
now i am applying above defined attribute syle in xml like
<Button
style="?attr/rectangleCustomButtonStatus1"
..... />
I am using Recyclerview, Recyclerview item has one button. Button text will be changed based on status like pending, completed. I want to set attribute style like if status is pending then use rectangleCustomButtonStatus1 and if status is completed then use rectangleCustomButtonStatus2.
So how can i give style attribute programmatically? same thing i have to do for recyclerview itemview's item. so how can i achieve this?