android setTypeface

时间:2011-09-24 09:22:25

标签: android android-layout

我有一个简单的主类

public void onCreate(Bundle savedInstanceState)
{       
    databaseHelper = new wecDatabasesManager(this); 
    databaseHelper.open(); 

    super.onCreate(savedInstanceState);
    series = databaseHelper.getSeries();

    startManagingCursor(series);

    setListAdapter(new SeriesListAdapter(this, series));

    registerForContextMenu(getListView());
}

我还有一个简单的适配器

public class SeriesListAdapter extends SimpleCursorAdapter
{
    public SeriesListAdapter(Context context, Cursor c) {
    super(context,R.layout.series_row, c, 
      new String[] { wecSeriesTable.NAME }, 
          new int[] {R.id.series_name});
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor)
    {    
      super.bindView(view, context, cursor);
      String SerieName = cursor.getString(cursor.getColumnIndex(wecSeriesTable.NAME));
    }
}

现在我的问题: 我该如何更改字体?

我找到了这段代码

Typeface font = Typeface.createFromAsset(getAssets(), "whatelsecomicsfont.ttf");
TextView txt = (TextView) findViewById(R.id.series_name);
txt.setTypeface(font);

我把它粘贴到我的主类中的getView方法但它不起作用 有什么想法吗?

1 个答案:

答案 0 :(得分:-1)

更改字体文件(* .ttf文件)