您尝试使用外部字体更改可扩展列表视图中的父文本(主题)的字体。我已将我的字体放在资源>字体中。我的代码中的上下文是红色的
subjects_adapter.java
public View getGroupView(int parent, boolean isExpanded, View convertView, ViewGroup parentView) {
String group_title = (String) getGroup(parent);
if (convertView == null){
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.parent_layout, parentView, false);
}
TextView parent_text_view = (TextView) convertView.findViewById(R.id.parent_text);
Typeface regular = Typeface.createFromAsset(context.getAssets(), "PLAYBILL.ttf");
parent_text_view.setTypeface(regular, Typeface.NORMAL);
parent_text_view.setText(group_title);
return convertView;
}
答案 0 :(得分:0)
Typeface regular = Typeface.createFromAsset(ctx.getAssets(),
"fontname.ttf");
parent_text_view.setTypeface(regular, Typeface.NORMAL);
在初始化parent_text_view后放入您的组视图
希望它运作良好