Nilanchala
Nilanchala

Reputation: 5941

Arabic + English text appears empty in android TextView

I am creating an android app that has multilingual support. Currently it is supporting more then 15 different languages. Everything was fine so far.

But now requirement is to mix English with Arabic. I have a ListView to render a ArrayList of values. ArrayList has few Arabic text and few elements are in English.

Arabic is appears fine across the app. but the English rows are not shown on the TextView. It is getting printed in logs.

Edit-1 It appears fine in android 2.3. So, my guess RTL is might be causing the problem.

Edit-2 Below is the screenshot of the app. As you can see in the right hand side some rows are white.

Here in right hand side rows, some of the data to be fetched from SQLite database and some are getting fetched from web. Data fetched from web is in Arabic, but SQLite data is in English.

Adapter getView() method is works fine. Inside getView() the data in both English and Arabic are printed. I have even printing getText() after setting text to the list rows, and getText() is even printing in English. Looks like the English rows are not getting printed or updated.

Attached Screenshot

Any help is much appreciated.

Upvotes: 3

Views: 1323

Answers (1)

Nilanchala
Nilanchala

Reputation: 5941

It is one of very strange observation on ListView rendering issue. I was initializing the adapter only while it is empty, any changes made or refresh was done was using notifyDataSetChanged(). But it was causing some delay in rendering.

if (mOptionsAdapter == null) {
        mOptionsAdapter = new CategoriesAdapter(mContext);
        final ArrayList<CategoriesItem> optionsList = getData();
        mOptionsAdapter.setDatasource(optionsList);
        mOptionsyListView.setAdapter(mOptionsAdapter);
        mOptionsAdapter.notifyDataSetChanged();
} else {
        mOptionsAdapter = new CategoriesAdapter(mContext);
        final ArrayList<CategoriesItem> optionsList = getData();
        mOptionsyListView.setAdapter(mOptionsAdapter);
        mOptionsAdapter.setDatasource(optionsList);
        mOptionsAdapter.notifyDataSetChanged();
}

Changed to, nullifying the adapter each time and recreating again solved the problem.

mOptionsAdapter = null;
mOptionsAdapter = new CategoriesAdapter(mContext);
final ArrayList<CategoriesItem> optionsList = getData();
mOptionsAdapter.setDatasource(optionsList);
mOptionsyListView.setAdapter(mOptionsAdapter);
mOptionsAdapter.notifyDataSetChanged();

I am not very sure, but i believe as RTL support wad made available from Android 4.0. It was not very much stable and causing rendering problem. Lucky Google has fixed that in 4.2, and it works great.

Upvotes: 5

Related Questions