3

I have a problem that I want to show a bulleted list contents which is resided in strings.xml file as an array elements. Then the problem is that how to convert the array elements in Html List format? Can any one suggest any solution regarding the same.

Thanks in advance

Sanat Pandey
  • 4,081
  • 17
  • 75
  • 132

4 Answers4

1

I just put the symbol directly into the strings.xml without any codes or anything:

<string name="msg_sms_no_note">• Notes and attachments will not be sent.</string>
Sileria
  • 15,223
  • 4
  • 49
  • 28
1

There's a problem with the approach suggested by some of the answers in this thread of prepending the bullet unicode character (i.e. \u2022) to each of the Strings in the String array: You don't get proper indentation when one or more Strings in the String array span multiple lines. What you get is formatting as follows:

Formatting with the bullet unicode character

In order to get proper indentation, you're better using BulletSpan. In doing so, you'll get formatting as follows:

Formatting with BulletSpan

To use BulletSpan, you need to create a SpannableStringBuilder instance and append each String in your String array to this SpannableStringBuilder instance. As you append each String, call the setSpan(what:start:end:flags:) method on the SpannableStringBuilder instance passing in a BulletSpan instance for the what parameter. You can find an example of this in the appendBulletSpan(...) Kotlin extension function located here.

Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
0

Use the unicode escape sequence "\u2022" in strings.xml

like so:

<string name="menu_new_trip_desc">View them in: \n\u2022 Table
ComeIn
  • 1,519
  • 17
  • 12
0

I think, the most elegant way of doing this is to load a WebView and put your string in it. this way, you use the common ul/li convention and you can style it at your leisure with CSS.

Sephy
  • 50,022
  • 30
  • 123
  • 131
  • Where would you add the css styling for this? – Jeff Feb 01 '13 at 20:21
  • This is a bad idea Webview sucks up way too much memory and is flawed in many ways. Use the • instead of the actual symbol. – JPM Feb 04 '15 at 19:14