我的数据对象中有一个 bool 变量,当它为 true 时,希望显示资源中的 1 个字符串,当它为 false 时,显示另一个字符串。 我正在尝试这样做:
android:text="@{sendit.bccMode ? @string/sharebox.bcc_mode_on : @string/sharebox.bcc_mode_off}"
但是出现编译错误:
****/ data binding error ****msg:Could not find accessor java.lang.String.bcc_mode_on
我做错了什么?
最佳答案
当您使用 . (点)作为名称,将您的 strings.xml
文件更改为:
<string name="sharebox_bcc_mode_on">BCC mode on</string>
<string name="sharebox_bcc_mode_off">BCC mode off</string>
关于android - 数据绑定(bind) : Choose one of string resources depends on condition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43872962/