custom font in android ListView

后端 未结 8 660
清歌不尽
清歌不尽 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:47

    In addition to the response of Moisés Olmedo - an alternative variant without creating a new class:

        tf = Typeface.createFromAsset(getAssets(), fontPath);
    
        recordsAdapter = new SimpleCursorAdapter(this, R.layout.item1, cursor, from, to);
    
        recordsAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
            public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
                if (columnIndex == 1) {
                    final TextView tv = (TextView) view;
                    tv.setTypeface(tf);
                }
                return false;
            }
        });
    

提交回复
热议问题