Bearded-Hen / Android-Bootstrap

Bootstrap style widgets for Android, with Glyph Icons
MIT License
7.29k stars 1.43k forks source link

How can I use Databinding for bootstrapText? #203

Open ashi-psn opened 7 years ago

ashi-psn commented 7 years ago

I want to put the FontAweSome icon on the left and want to display the text obtained from the model to the right. I thought that the part of Databinding had to be escaped, and wrote the code as app:bootstrapText="{fa_tag} "@{xxx.xxx}"". However, an exception Caused by: java.lang.IllegalArgumentException: Could not find FontIcon value for 'xxx.xxx', please ensure that it is mapped to a valid font occurred. I tried it elsewhere, but eventually I did not solve it. How do I use Databinding for bootstrapText?

jamie-beardedhen commented 7 years ago

FontIcons can be escaped through XML in the following way:

app:bootstrapText="Escaped \{fa_facebook\} icon (gravity=start)"

I'm assuming you're talking about the Android Databinding library. If that's the case, then the two aren't currently compatible. It should be possible to update the code which parses BootstrapText to ignore databinding syntax, although I'm not too familiar with databinding - is @{var} the only syntax used or are there others?

Relevant code: https://github.com/Bearded-Hen/Android-Bootstrap/blob/master/AndroidBootstrap/src/main/java/com/beardedhen/androidbootstrap/IconResolver.java