是否可以将myFont设置为String [],我正在做类似的事情 我想将Font设置为R.id.txt,但所有值都通过String []
传递给HashMap
optionsMenuList.setAdapter(new SimpleAdapter(getApplicationContext(),
array, R.layout.custom_list_row,
new String[] { "Name", "Image" }, new int[] { R.id.txt,
R.id.music }));
((TextView) findViewById(R.id.txt)).setTypeface(Title);
答案 0 :(得分:0)
为TextView创建一个对象
TextView tv;
Typeface typeface = Utils.getTypeFace(activity, <get that font here)>); // get fontstyle from assets if you added
tv=(TextView) findViewById(R.id.txt);
tv.setTypeface(typeface);
public static Typeface getTypeFace(Context context, String type) {
if (TextUtils.isEmpty(type)) {
return Typeface.createFromAsset(context.getAssets(), fonts/SegoeRg.ttf);
}
答案 1 :(得分:0)
如果您的R.id.txt属于custom_list_row xml,那么
optionsMenuList.setAdapter(new SimpleAdapter(this, array, R.layout.custom_list_row, new String[] {"Name", "Image"}, new int[] {R.id.txt, R.id.music}));
在你的适配器类中,getView方法
Context ctx;
SimpleAdapter(Context ctx, Object[] array, int layout, String[] stringarray, int[] intarray) {
this.ctx = ctx;
}
View v = ctx.getLayoutInflater().inflate(R.layout.custom_list_row, null);
((TextView) v.findViewById(R.id.txt)).setTypeface(Title);