我在這裏有一個代碼,我想在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