当我更改当前活动上所有文本视图的字体时,除了 Textview 文本外,所有文本都发生了变化。
但是当我从 listview 的 itemclick 侦听器调用相同的函数时,字体会发生变化
((TextView) view).setTypeface(CreateTypeface);
如何设置列表视图的字体而无需单击它?
final View rootView = findViewById(android.R.id.content);
public void applyCustomFont(ViewGroup list)
{
for (int i = 0; i < list.getChildCount(); i++) {
View view = list.getChildAt(i);
if (view instanceof ViewGroup)
{
applyCustomFont((ViewGroup) view);
} else if (view instanceof TextView)
{
((TextView) view).setTypeface(CreateTypeface);
}
}
}
lvfonts.setAdapter(new ArrayAdapter<String> (FontMUI.this,android.R.layout.simple_list_item_1, list));
lvfonts.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3)
{
applyCustomFont((ViewGroup)rootView);
}
}