FDupie FDupie - 2 months ago 24
Android Question

Hebrew and normal text not displaying right

I'm trying to display Hebrew and normal text mixed, the text comes from a SQLite database and is displayed in a listview that gets pulled from my database in the Assets folder.

I want to display the following:

‘אנא אנא - Ek is, was, sal wees Wie Ek is, was, sal wees.”

But it gets displayed as:

”.Ek is, was, sal wees Wie Ek is, was, sal wees - אנא אנא‘

When the hebrew text is between other normal text its fine like:

‘He says אנא אנא - I am, was, shall be Who I am, was, shall be.”

The text only gets mixed up when the listview item starts with Hebrew.

I've tried:

‘<\U+200f>אנא אנא<\U+200f> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘<\U200f>אנא אנא<\U200f> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘\U200fאנא אנא\U200f - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘(\U200f)אנא אנא(\U200f) - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘<\U+202b>אנא אנא<\U+202b> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘<\U202b>אנא אנא<\U202b> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘\U202bאנא אנא\U202b - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘(\U202b)אנא אנא(\U202b) - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘<\U+202e>אנא אנא<\U+202e> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘<\U202e>אנא אנא<\U202e> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘\U202eאנא אנא\U202e - Ek is, was, sal wees Wie Ek is, was, sal wees.”

‘(\U202e)אנא אנא(\U202e) - Ek is, was, sal wees Wie Ek is, was, sal wees.”

But everything gets displayed with the codes like:
(I dont want to see the codes)

‘<\U+200f>אנא אנא<\U+200f> - Ek is, was, sal wees Wie Ek is, was, sal wees.”

Ive tried android:supportsRtl="true" in the manifest, this only affects the text allignment in my case and not the texts.

Answer

Sooo... This finally worked for me....

textview.setTextDirection(View.TEXT_DIRECTION_LTR);

Please note that my problem was as I said, Im reading data from a database and not displaying strings, so this code forces all data to be read from left to right, if I do not use this line, It picks up the Hebrew characters as RTL text and wants to display the whole result as RTL.

Thanks for all the help though! I had a lot of reading and learned in the process!

Comments