custom font in android ListView

后端 未结 8 709
清歌不尽
清歌不尽 2020-11-29 06:15

I\'m using a custom font throughout my application (which, incidentally, I\'ve frustratingly found out that you have to apply programmatically by hand to EVERY control!), an

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 06:37

    Try like this for arrayadapters::

    Typeface typeNormal = Typeface.createFromAsset(getAssets(), "roboto_lite.ttf");
    
    timearray = new ArrayAdapter(DetailsActivity.this,R.layout.floorrow,R.id.txt, flor) {
        public View getView(int pos, View convertView, android.view.ViewGroup parent) {
            View v = convertView;
            if (v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.floorrow, null);
            }
            TextView tv = (TextView)v.findViewById(R.id.txt);
            tv.setText(flor.get(pos));
            tv.setTypeface(typeNormal);
            return v;
        }; 
    };
    
    lv_building.setAdapter(timearray);
    

提交回复
热议问题