我似乎无法弄清楚如何为字符串数组设置自定义字体。
String quizname[] = {"Cricket", "Football", "Tennis", "Golf", "Rugby", `"Hardcore",};`
我知道如何为文本视图设置自定义字体,但不确定在网格视图中如何为字符串设置
Typeface custom_font = Typeface.createFromAsset(getAssets(), "slant.TTF");
prefs = getSharedPreferences("appPurchase", 0);
editor = prefs.edit();
textView.setTypeface(custom_font);
textView.setTextColor(getResources().getColor(R.color.gold));
custGridList = new ArrayList<>();
for (int i = 0; i < quizname.length; i++) {
CustGridList list = new CustGridList();
list.setQuizImg(imgs[i]);
list.setQuizName(quizname[i]);
custGridList.add(list);
}
答案 0 :(得分:0)
您可以在onBindViewHolder
的recyclerView项目中设置字体。
示例:
class Holder extends RecyclerView.ViewHolder {
TextView t;
public Holder(View itemView) {
super(itemView);
t = itemView.findViewById(R.id.text);
}
}
并在您的onBindViewHolder
@Override
public void onBindViewHolder(@NonNull Holder holder, int position) {
holder.t.setTypeface(custom_font);
}