I am displaying data in a TextView that is being retrieved from a remote source. Sometimes that text contains characters that don't display properly in my TextView. For example, & shows as &
I tried:
text = Html.fromHtml(text).toString();
Then the characters display properly, but all of the text appears on one line, even if it doesn't fit on one line. From there I tried setting textView.setSingleLine(false); but it still shows as one line of text.
How can I get this text to show the characters properly and also show as multiple lines when necessary? Other solutions suggest manually putting the characters in a string variable, or displaying the characters programmatically, but since it's text that is pulled from the web that isn't possible.
Split your data into separate lines, call fromHtml on each and then join them back together.
Related
I have a text showing in the textview which is displayed correctly since years (Productive App), but now I get a nondisplayable Character as result (?)
textViewBottom.setText("Übersicht");
is showing as
?bersicht.
How can I achieve showing the special character correctly and does one know what could be changed ?
I am trying to show a text in my android app using special unicode characters (Look like letters).
One character always is correspondending to tow unicode characters:
The first one is always '\uD83C' (55356) which is follwed by '\uDDF9' (56825) for 'A' for example (56826 for 'B' etc...). Setting the text generally works fine but whenever the text contains a substring which correpondens to a country encoding (Like 'ES' for Spain) it does not show the two characters but the flag instead.
I already tried to understand this behaviour and searched for possibilites to turn i did not find any soloutions
Example:
I want to show these characters: 🇹🇪🇸🇹
String value as char array:
Result in my TextView:
Can you help me find a way to disable this behaviour. I already seen it working in other apps.
The characters you are using only exist to produce flag emoji; they serve no other purpose and are not intended to be used for “fancy” text. Displaying flags for valid region codes is their only correct behaviour.
If you absolutely have to use them without that happening, you need to insert invisible characters inbetween every letter to break up the ligatures, for example U+200C (Zero Width Non-Joiner) or U+2060 (Word Joiner).
I am working on an Android app for tourists where I show a list of all rooms in my city for accomodation. I have approximately 500 lines of text, about 5 lines for each room (adress, phone number, contact person, email adress and stars rating). I want to put all that text in one activity so you can scroll and read that text.
Should I use TextView or something else? Should I save that whole text in res/strings.xml?
There is no problem with using TextViewsjust do not forgot about using ScrollView for your layout so you can scroll your TextViews.
You could use a WebView and display the text in HTML format.
I did it for big documents and used the assets folder to store and load the document.
Internationalization can be kept using following technique:
What's the best practice to deploy localized documents in Android app?
I am developing an Android application and I have displayed a story using TextView. I want that if the user tap on a particular word, it will copy that word and send it to the dictionary within the application and search for its definition. How do I do that? How do I know what word is tapped by the user since the TextView consists of around hundred words.
In same case I used array of textViews. To make it this way you should prepare text, for example split text with " ".
The second way is to use WebView, text as html doc and some javascript.
In my android application, I am displaying a long string into multiple pages. I achieve this by breaking the long string into a string array where every array element holds the number of characters which can fit on one screen (without scrolling). Also by using a previous/next button at the bottom of my activity I change the content of my textview to switch between pages(array elements).
Where I am stuck is in finding out how many characters will show on one page/screen. Remember I don’t want user to scroll. I use the paint.breaktext with screenwidth as the parameter and find out how many characters go in one line and then multiply it by number of lines on one screen to get the number of characters in a page. Android’s text wrapping at the end of each line is what gets my calculation of finding characters in a page, wrong. I am trying to put my own logic to accommodate for text wrapping but that is not working.
So my question is:
Is there any way I can find out that how many characters will show in one screen?
Or what can also help me is if I find out what logic is followed by android for wrapping the text for newline. Because if I know that, then I can readjust my number of characters on a page accordingly.
Or other option could be to disable text wrapping (not sure if possible). Because then I can use my own logic to wrap the text rather than trying to figure out Android’s text wrapping logic and adjusting my character-on-a-page accordingly.
Any help is much apreciated.