开发者社区 问答 正文

用getAssets()出现context cannot be resolved

Typeface customFont = Typeface.createFromAsset(this.getAssets(), "幼圆.ttf");
 TextView view = (TextView) findViewById(R.id.tv);
 view.setTypeface(customFont);

再debug时候出现了context cannot be resolved

展开
收起
爵霸 2016-03-20 12:51:16 2406 分享 版权
1 条回答
写回答
取消 提交回答
  •  AssetManager mgr = getActivity().getAssets();//得到AssetManager
        Typeface tf = Typeface.createFromAsset(mgr, "fonts/jdxsj.TTF");//根据路径得到Typeface
    2019-07-17 19:09:26
    赞同 展开评论
问答地址: