字体中的AssetsManager

时间:2013-04-22 15:32:59

标签: android

Typeface.createFromAsset(AssetManager mgr,String path); 怎么用呢?

AssetManager mgr;
tf = Typeface.createFromAsset(mgr, font);
TextView txtName = (TextView) convertView.findViewById(R.id.txtTitle);
txtName.setText(novena.getName());
txtName.setTypeface(tf);

如何初始化mgr?

你可以用 tf = Typeface.createFromAsset(context.getAssets(),font);

2 个答案:

答案 0 :(得分:5)

像这样:

AssetManager mgr;
...
mgr = getAssets();

答案 1 :(得分:5)

//If you are inside of an ACtivity, and NOT inside of an inner class
AssetManager mgr = getAssets();