0

我想知道如何在java中设置字体大小列表视图..有人想帮忙吗?

这是我的 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);

谢谢你:)

4

1 回答 1

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;
        }
    }
于 2012-10-22T15:23:25.623 回答