I.S
I.S

Reputation: 2053

How to have space and special character in data bind-ed xml?

  android:text="@{'\u2022' +item.title}"

I'm using data binding and should space + bullet + space + title put when I add space it breaks

Upvotes: 1

Views: 1068

Answers (2)

George Mount
George Mount

Reputation: 20926

You should be able to do what you suggest in the question:

android:text="@{`\u0020\u2022\u0020` + item.title}"

But it is better to use string formatting:

<string name="bullet"> \u2022 %1$s</string>

and use it like this:

android:text="@{@string/bullet(item.title)}"

I'm pretty sure that \u0020 is just a normal space, so I just used a normal space in the string resource.

Upvotes: 3

I.S
I.S

Reputation: 2053

I want to answer my question

android:text="@{(@string/space).concat(@string/bullet).concat(@string/space).concat(item.title)}"


<string name="space">\u0020</string>
<string name="bullet">\u2022</string>

Upvotes: 0

Related Questions