我正在尝试在自定义可扩展列表视图中使用自定义字体。但是,当我尝试执行此操作时,最初,当加载 Viewpager 片段(我使用的)时,ExpandableListView 的文本和字体不可见。
一旦我单击可扩展列表视图中的空白文本,就会显示文本和字体。这个问题似乎只发生在自定义字体上。如果我使用任何其他自定义功能(例如更改 textview 的颜色等),它会运行良好。请帮助
请参阅所附图片以供进一步参考:
我的自定义可扩展列表适配器代码的相关部分:
public class MyExpandableListAdapter extends SimpleExpandableListAdapter {
View cntView;
LayoutInflater inflater;
Context cxt;
TextView tvGrp, tvChild;
public MyExpandableListAdapter(Context context,
List<? extends Map<String, ?>> groupData, int groupLayout,
String[] groupFrom, int[] groupTo,
List<? extends List<? extends Map<String, ?>>> childData,
int childLayout, String[] childFrom, int[] childTo) {
super(context, groupData, groupLayout, groupFrom, groupTo, childData,
childLayout, childFrom, childTo);
cxt=context;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
super.getGroupView(groupPosition, isExpanded, convertView, parent);
View tmp;
if (convertView == null) { // if it's not recycled, initialize some attributes
tmp=new View(cxt);
inflater=(LayoutInflater)cxt.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
tmp=inflater.inflate(R.layout.explistgroup, null);
}else{
tmp = (View)convertView;
}
tvGrp=(TextView) tmp.findViewById(R.id.rowTextView);
tvGrp.setTypeface(FontLoader.loadTypeface(cxt,R.raw.roboto_regular)); // This does not work. It shows a blank textview initially. Only after I click it, the typeface and the text come into effect
//tvGrp.setText("ambit"); -- This works well
return tmp;
}