on 04-09-2017 5:35 PM
Hello, I am trying to change color of an icon of a StandardListItem.
On press function, I want to create a new icon and set it to the StandardListItem object.
detailPressed: function(oEvent) {
var oIcon = new sap.ui.core.Icon({
src : "sap-icon://alert",
color: "#333333"
});
oEvent.getSource().setIcon(oIcon.getSrc());
}
But since setIcon method of StandardListItem takes only URI of the icon, color is not taken into account. Could you please tell me how to change color icon?
Thank you.
you approach is wrong, check the link below may help you:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Two options:
1)
Use expression binding for the src and color https://help.sap.com/saphelp_uiaddon10/helpdata/en/da/f6852a04b44d118963968a1239d2c0/content.htm and update the model. Once the model is updated onPress, the icon and color will be updated
<core:Icon
src="{= ${pressed} === '0' ? 'sap-icon://sys-enter' : 'sap-icon://alert' }"
color="{= ${pressed} === '0' ? 'green' : 'red' }"
tooltip="{= ${pressed} === '0' ? ${i18n>unpressed} : ${i18n>pressed} }"
/>
2)
Use a string for color like "red" with the previous code but instead of adding a new Icon, reconfigure the existing one.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.