1

in Android I would like to concatenate number with Arabic text. but if i concatenate the number then the arabic text direction changes.

Example: My Application reads each line of arabic text from file and adds the line number to each line and appended to string builder , After completion of reading final string will be displayed on text view.

Here is my code

SpannableStringBuilder styledString = new SpannableStringBuilder(TextUtils.concat(l,"("+sn+")"));
                styledString.setSpan (new CustomTypefaceSpan("", type), 0, l.length()-1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
               // styledString.setSpan(new    AlignmentSpan.Standard(Layout.Alignment.ALIGN_OPPOSITE),l.length()-1,l.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                spannablestringbuilder.append(styledString);

Expected Output: (3) ﺑِﺴْﻢِ ٱﻟﻠَّﻪِ ٱﻟﺮَّﺣْﻤَٰﻦِ ٱﻟﺮَّﺣِﻴِ(1)ٱﻟْﺤَﻤْﺪُ ﻟِﻠَّﻪِ ﺭَﺏِّ ٱﻟْﻌَٰﻠَﻤِﻴﻦَ (2) ٱﻟﺮَّﺣْﻤَٰﻦِ ٱﻟﺮَّﺣِﻴﻢِ

enter image description here

Actual Output (1)ﺑِﺴْﻢِ ٱﻟﻠَّﻪِ ٱﻟﺮَّﺣْﻤَٰﻦِ ٱﻟﺮَّﺣِﻴﻢِ (2)ٱﻟْﺤَﻤْﺪُ ﻟِﻠَّﻪِ ﺭَﺏِّ ٱﻟْﻌَٰﻠَﻤِﻴﻦَ ٱﻟﺮَّﺣْﻤَٰﻦِ(3) ٱﻟﺮَّﺣِﻴﻢِenter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267

1 Answers1

0

Try

  1. Removing spaces
  2. Use hyphens - instead of spaces
  3. Try finding a way to change the direction

By the way, this question is answerde here and might be a duplicate!

Thanks for posting!

Community
  • 1
  • 1
hannunehg
  • 318
  • 2
  • 12