相关疑难解决方法(0)

从资产访问一次字体并将其用作参考

我正在尝试创建一个返回titleFont和contentFont字体的方法,以便通过返回引用和减少代码长度来提高效率.我知道这很简单,但我没有办法.任何人都可以帮忙.或任何其他选择将被赞赏..抱歉英语不好

这是多次运行的方法..

protected void onPostExecute(Article result) {
    super.onPostExecute(result);

    TextView txtTitle= (TextView) view.findViewById(R.id.title);
    txtTitle.setTypeface(titleFont);
    txtTitle.setText(result.getTitle());

    private Typeface titleFont=Typeface.createFromAsset(context.getAssets(),"fonts/InterstateCondMonoLgt.ttf");
    private Typeface contentFont=Typeface.createFromAsset(context.getAssets(),"fonts/InterstateLight.ttf");

    TextView txtMain= (TextView) view.findViewById(R.id.main);
    txtMain.setTypeface(contentFont);
    txtMain.setText(result.getContent());
}
Run Code Online (Sandbox Code Playgroud)

android

2
推荐指数
1
解决办法
3074
查看次数

标签 统计

android ×1