Question

I want to use Arabic language inside html tags in android application,
the html tags are in the strings.xml file and its works perfectly with English language,
when I added Arabic version of the strings.xml file every thing is OK but the html string becomes understandably language ??
I tried to add

<head>
    <meta http-equiv="Content-Type" ; content="text/html; charset=utf-8" ; />
</head>

but the problem still. how can I fix it ??

Was it helpful?

Solution

yesss I found it,
I have to load the text this way in my activity
aboutus.loadData(stringData, "text/html; charset=UTF-8", null);

OTHER TIPS

Did you changed the Locale of your device?

Your Arabic string file must be in this value folder. "values-ar"

In your activity class, change your device Locale through code for your application. You may call it on menu or a button pressed.

        String languageCode = "ar_EG";
    Resources res = getResources();
        DisplayMetrics dm = res.getDisplayMetrics();
        android.content.res.Configuration conf = res.getConfiguration();
        conf.locale = new Locale(languageCode.toLowerCase());
        res.updateConfiguration(conf, dm);
        // you need to restart activity so that this change take place
        startActivity(new Intent(this, MyActivity.class));
        finish();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top