Reputation: 61
I am trying to show a list of crops in Bangla/Bengali in the android app. I already have an array of crops in english like String[] crops={"paddy","potato","gourd"};
showing corresponding bangla name in app like if I want to show only "potato",the app will show "আলু"
I followed the steps shown here: http://www.thedevline.com/2014/08/how-to-build-bangla-language-support.html
But it did not show bangla though app was run. I am working in android studio. Can anyone please help ? I have following function in databaseAccess.java file here
Upvotes: 1
Views: 1933
Reputation: 957
Download library file from`
https://github.com/androidbangladesh/BLS_SAMPLE_APP
and place it to app\libs
folder.
Now on build.gradle
file simply add
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/bls-1.0.jar')
}
For more information you may visit: http://www.thedevline.com/2014/08/how-to-build-bangla-language-support.html
Upvotes: 0
Reputation: 23881
try using a custom adapter for listview with your font set
public class MyArrayAdapter extends ArrayAdapter<String> {
private final Context context;
private final String[] values;
public MyArrayAdapter(Context context, String[] values) {
super(context, R.layout.list_item, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.list_item, parent, false);
TextView textView = (TextView) rowView.findViewById(R.id.label);
//here use your true type font of Bangla like this bangla.ttf is placed inside asset/fonts/ folder of project
Typeface face=Typeface.createFromAsset(getAssets(), "fonts/bangla.ttf");
textView .setTypeface(face);
textView.setText(values[position]);
return rowView;
}
}
use it in your Activity like:
String[] names = new String[] { "আলু", "পেয়াজ", "বাদাম"};
ListView myListView=(ListView)findViewById(android.R.id.list); //your listview
myList.setAdapter(new MyArrayAdapter(this, names));
in res/layout: R.layout.list_item
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="5dp"
android:singleLine="false"
android:text="Text"
android:textSize="15sp" />
Upvotes: 1