我在这里有一个代码,我想在listview中更改字体并将其显示在listadapter中。然而,它并没有帮助,只是显示一个默认的数字而不是实际的数据。这是改变我的数据字体的正确方法吗?如何在listadapter的listview中显示自定义字体中的数据?
ListAdapter adapter = new SimpleAdapter(
AllProductsActivity3.this, productsList,
R.layout.list_item3, new String[] { TAG_PID,
TAG_NAME, TAG_PRICE, TAG_DESCRIPTION},
new int[] { R.id.pid, R.id.username,R.id.p_title, R.id.approval }){
@Override
public View getView(int pos, View convertView, ViewGroup parent){
View v = convertView;
if(v== null){
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v=vi.inflate(R.layout.list_item3, null);
}
TextView tv = (TextView)v.findViewById(R.id.username);
Typeface custom_fontG = Typeface.createFromAsset(getAssets(),
"fonts/orange juice 2.0.ttf");
tv.setTypeface(custom_fontG);
TextView tv2 = (TextView)v.findViewById(R.id.p_title);
Typeface custom_fontH = Typeface.createFromAsset(getAssets(),
"fonts/orange juice 2.0.ttf");
tv2.setTypeface(custom_fontH);
TextView tv3 = (TextView)v.findViewById(R.id.approval);
Typeface custom_fontI = Typeface.createFromAsset(getAssets(),
"fonts/orange juice 2.0.ttf");
tv3.setTypeface(custom_fontI);
return v;
}
检查:http://stackoverflow.com/questions/26505109/how-to-use-custom-font-in-custom-baseadapter/ 26505473#26505473 – 2014-11-03 12:39:49
其实您的问题标题与您的问题描述无关。 – 2014-11-03 12:47:54