Android Replace "..." with ellipsis character
Asked Answered
P

8

324

Since AVD tools 16 I'm getting this warning:

Replace "..." with ellipsis character (..., …) ?

in my strings.xml

at this line

 <string name="searching">Searching...</string>

How do I replace ...? Is it just literally &#8230;?

Could someone explain this encoding?

Parisian answered 16/12, 2011 at 15:33 Comment(3)
As a note, I've noticed that some of Android's own translated string files use … itself rather than the Unicode entity. Given that Android XML files are normally encoded in UTF-8 anyway, I see no reason not to use the character itself rather than the potentially-esoteric Unicode entity, especially as most word processing programs these days support autocorrecting "..." to "…" (Microsoft Word does it by default, last I checked).Duleba
Is it actually three dots (ASCII 46 / 0x26)? Or ASCII 133 (one character)?Councilwoman
At the answer of another SO question, there's a better explanation than 'Change ... into the Unicode because it's better'. https://mcmap.net/q/100892/-why-gradle-lint-think-ellipsis-character-quot-amp-8230-quot-is-more-readable-than-quot-quot In short, it prevents the three dots from being split on a multi line text (showing 1 or 2 dots alone) and in some typographies it looks bad to see 3 dots.Bracer
C
558

&#8230; is the unicode for "" so just replace it. It's better to have it as one char/symbol than three dots.

Complexioned answered 16/12, 2011 at 15:39 Comment(13)
Thanks when I understand unicode, when I was first replacing it, eclipse was changing my & into &amp; (I had double &&) . Fixed!Parisian
Why is it "better"? This complicates things when giving the text to translators. Can we somehow kill this stupid warning? ThanksNeighbors
@Neighbors Yes you can disable it in the project properties. Anyway, as a German I can guarantee you, that I prefer English over translated nonsense (when you refer to translator software, not professional ones)Complexioned
@Neighbors good to know :) but as they are payable, they are teachable, too :)Complexioned
@Neighbors see florian answerGizmo
@Neighbors It's "better" in part because it doesn't break ("..." might wrap around on e.g. the second period), and theoretically languages could render them differently (many asian languages put them in the middle and they're wider (matches a character width)). Non-breaking is useful everywhere, I'm not aware of Android rendering them correctly in other langs though, nor am I aware of UTF characters for this purpose.Hillard
Having "..." causes accessibility issues. Android Talkback reads "Loading..." as "Loading 3 period"Eleni
@MohammadShabazMoosa interesting. Thanks for sharing that! Can you also share if it says "dot dot dot" in case of use three dots instead of that special char?Complexioned
It seems my comment wasnt clear. Using "loading..." (3 dots) leads Talkback to say "loading 3 period" Using "Loading&#8230;" (ellipsis) leads Talkback to say "Loading" [Which is good.. ] So, we should use ellipsis alwaysEleni
@MohammadShabazMoosa ah got you! Thanks for clearing that up!Complexioned
@Neighbors you don't really have to use XML code character, you can just paste the "…" character. The same applies for typewriter quotes.Stonemason
Always remember to put the ; in the endMcneill
@MohammadShabazMoosa This doesn't appear to be the case anymore, at least on my test on Android 11.Directorial
C
16

To make thing short just put &#x2026; in place ...

Link to XML character Entities List

  • Look at Unicode column of HTML for row named hellip
Chou answered 29/6, 2012 at 23:24 Comment(3)
I initially wondered why you used &#x2026; when the Eclipse warning says to use &#8230; but your link does answer that. Namely that the x signifies a hex value and 8230 in decimal is 2026 in hex.Hymanhymen
where to put this &#x2026 any location for this.Kopaz
@TusharPandey- if your code is <string name="searching">Searching...</string> then it will look something like <string name="searching">Searching&#x2026</string>Chou
M
13

If you're using Eclipse then you can always do the following:

  • Right click on the warning
  • Select "Quick Fix" (shortcut is Ctrl + 1 by default)
  • Select "Replace with suggested characters"

This should replace your three dots with the proper Unicode character for ellipsis.

Just a note: The latest version of ADT (21.1) sometimes won't do the replace operation properly, but earlier versions had no problem doing this.

This is the character:

Mokpo answered 19/3, 2013 at 17:43 Comment(3)
This worked for me! However nothing "visual" happened other than the warning disappeared, and I'm running ADT 22.2.1. But i guess thats how it works :)Alsatian
Didn't worked for me. Eclipse sugested me (I don't know why) to surroud <resources> tag with a new <element> tag.Khanna
Eclipse will do that sometime if you don't exactly highlight the right area. I find myself highlighting and trying to quick fix two or three times before it actually makes the right suggestion.Mokpo
S
8

The solution to your problem is:

Go to Window -> Preferences -> Android -> Lint Error Checking

And search for "ellipsis". Change the warning level to "Info" or "Ignore".

Scullion answered 24/11, 2012 at 17:6 Comment(4)
Those suggestions do make sense. Simply ignoring them is only a solution, if you are really sure, what you are doing. In this case, the replacement makes sense, so ignoring the warning is not good.Mcclintock
Thanks! Just what I was looking for. And that's the place to do all sorts of related things (I don't need a computer to tell me how to spell, capitalize, or punctuate). Very useful!Vanesavanessa
this is not a good option to do ignore the warnings. you should fix the warnings for better results.Cornstalk
@ScottBiggs to be fair, if the computer is telling you that you have spelled, capitalized, or punctuated something incorrectly, then you ought to fix it. Lints are useful in that regard, I advise against disabling them.Shadshadberry
K
3

This answer is indirectly related to this question:

In my case textView1.setTextView("done&#8230"); was showing some box/chinese character. Later, I checked into fileformat.info for what the value represents and I found this is a Han character. So, what to do? I searched for "fileformat.info ellipse character" and then everything became clear to me once I saw its values are;

UTF-16 (hex) 0x2026 (2026)

UTF-16 (decimal) 8,230

So, you have several encoding available to represent a character (e.g. 10 in Decimal is represented as A in hexa) so it is very important to know when you are writing an unicode character, how receiving function decodes it. If it decodes as decimal value then you have to provide decimal value, if it accept hexadecimal then you have to provide hexadecimal.

In my case, setTextView() function accepts decimal encoded value but I was providing hexadecimal values so I was getting wrong character.

Karafuto answered 12/4, 2014 at 15:19 Comment(0)
F
3

The quick fix shortcut in Android Studio is Alt + Enter by default.

Faxen answered 17/12, 2018 at 14:54 Comment(0)
G
1

Best not to ignore it as suggested by some, it seems to me. Use Android Studio to correct it (rather than actually typing in the character code), and the tool will replace the three dots with the three-dot unicode character. Won't be confusing to translators etc.

Ghazi answered 31/12, 2019 at 10:37 Comment(0)
V
0

In Android, just use the single character: …

Vespertine answered 21/11, 2023 at 3:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.