这是我的代码:
String[] filled_arr;
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item, R.id.tv_wi, filled_arr);
listview.setAdapter(adapter);
这是字体:
final Typeface typeface = Typeface.createFromAsset(getAssets(), "Constantia.ttf");
如何为适配器设置它?
最佳答案
我已经通过覆盖数组适配器解决了这个问题。希望,它会帮助别人)
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),
android.R.layout.simple_list_item_1, filled_arr) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = super.getView(position, convertView, parent);
TextView text = (TextView) view.findViewById(android.R.id.text1);
text.setTypeface(typeface);
return view;
}
};
关于android - 为 arrayadapter 设置自定义字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37081697/