为什么不在Android Studio中显示Bangla单词?
问题描述:
我想在android应用程序中显示Bangla/Bengali中的作物列表。我已经有作物的数组中英文像String[] crops={"paddy","potato","gourd"};
显示应用相应孟加拉的名字一样,如果我想只显示“土豆”,应用程序会显示“আলু” 我跟着此处显示的步骤:http://www.thedevline.com/2014/08/how-to-build-bangla-language-support.html为什么不在Android Studio中显示Bangla单词?
但它没有显示孟加拉,但应用程序运行。我在android studio工作。 任何人都可以请帮忙吗? 我在databaseAccess.java文件下列功能与您的字体设置
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;
}
}
在活动中使用它像 here
答
尝试使用自定义的适配器列表视图:
String[] names = new String[] { "আলু", "পেয়াজ", "বাদাম"};
ListView myListView=(ListView)findViewById(android.R.id.list); //your listview
myList.setAdapter(new MyArrayAdapter(this, names));
在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" />
答
下载库文件from`
https://github.com/androidbangladesh/BLS_SAMPLE_APP
,并放置在app\libs
文件夹。
现在在build.gradle
文件只需添加
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/bls-1.0.jar')
}
欲了解更多信息,可访问: http://www.thedevline.com/2014/08/how-to-build-bangla-language-support.html
发布您的代码.. – rafsanahmad007
你尝试过什么到目前为止?有什么例外?错误? –
我试图按照链接http://www.thedevline.com/2014/08/how-to-build-bangla-language-support.html中的步骤运行给定的代码。虽然应用程序运行但不显示文本。它是空白的 – suptagni