我想知道如何在java中设置字体大小listview .. 有人想帮忙吗?
这是我的listview代码:
Categories weather_data[] = new Categories[]
{
new Categories(R.drawable.dokter, "Cardiology"),
new Categories(R.drawable.dokter, "Dentistry"),
new Categories(R.drawable.dokter, "Dermatology and Venereology"),
new Categories(R.drawable.dokter, "Disgetive Surgery"),
new Categories(R.drawable.dokter, "ENT")
};
CategoriesAdapter adapter = new CategoriesAdapter(this,R.layout.listcategoriesitem, weather_data);
lvcategories = (ListView)findViewById(R.id.lvcategories);
lvcategories.setBackgroundResource(R.drawable.bawah2);
lvcategories.setAdapter(adapter);
你:)
答案 0 :(得分:0)
您可以使用自定义适配器:
private class CategoriesAdapter extends ArrayAdapter<Categories> {
public CategoriesAdapter (Context context, int textViewResourceId,
ArrayList<Categories> items) {
super(context, textViewResourceId, items);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
Categories o = this.getItem(position);
if (o != null) {
TextView tt = (TextView) v.findViewById(R.id.tvCategoryName);
if (tt != null) {
tt.setText(o.getName());
tt.setTypeface(typeface);
}
}
return v;
}
}