0

Javaでフォントサイズのリストビューを設定する方法を知りたい..誰か助けたいですか?

ここにリストビューの私のコードがあります:

    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 に答える