Android : Android Arabic Text Concatination

on Monday, February 16, 2015


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


0 comments:

Post a Comment