setFontFeatureSettings错误noSuchMethodError

时间:2015-10-09 06:49:02

标签: android css fonts typeface

我想在备用分数中写下数字。

1
_<BR>
2

而不是1/2。为此我使用了代码

Typeface typeface = Typeface.createFromAsset(getAssets(), "Nutso2.otf");
vText.setTypeface(typeface);

vText.setText("1/2");
vText.setFontFeatureSettings("afrc");

但我收到此错误

com.example.kashif.equationsolver E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.kashif.equationsolver, PID: 4746
    java.lang.NoSuchMethodError: android.widget.TextView.setFontFeatureSettings
            at  com.example.kashif.equationsolver.MainActivity$3.onClick(MainActivity.java:331)
            at android.view.View.performClick(View.java:4438)
            at android.view.View$PerformClick.run(View.java:18422)
            at android.os.Handler.handleCallback(Handler.java:733)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5001)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
            at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

遗憾的是,

setFontFeatureSettings只能从Lollipop(21)开始提供,你以前不能使用它!