log cat中的字体错误

时间:2015-01-07 09:59:51

标签: android

我正在编写波斯语应用程序,我需要将列表视图的项目从英语更改为波斯语但我得到了类型面错误,我不知道是什么问题导致我跟随教师。(我是m使用android studio)
  这是班级

public class SplashScreenActivity extends Activity {
public String fonts = "BZar.ttf";
@Override
    public void onCreate (Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splashscreen);

    Typeface face = Typeface.createFromAsset(getAssets(),  "font/" +fonts+"");
    TextView app_full_name=(TextView)findViewById(R.id.app_full_name);
    app_full_name.setTypeface(face);
    **String str_full_name = (String)  app_full_name.getText();
    app_full_name.setText(PersianReshape.reshape(str_full_name));**

       final int SplashScreenActivity_DISPLAY_LENGTH = 1000;


        Handler h = new Handler();
        h.postDelayed(new Runnable() {
            @Override
            public void run() {
            }
        }, SplashScreenActivity_DISPLAY_LENGTH);
    Intent intent = new Intent(this , MainListActivity.class);


    startActivity(intent);}
}

activity_splashscreen.xml

 <ImageView android:layout_width="wrap_content"
 android:id="@+id/app_logo"
 android:src="@drawable/app_logo"
 android:layout_height="wrap_content"
 android:scaleType="centerInside"
 android:contentDescription="@string/app_name"/>

<TextView
    android:id="@+id/app_full_name"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="@string/app_full_name"
    android:textColorHint="#16a085"
    android:layout_marginTop="20dp"
    android:scaleType="centerInside"/>

<TextView
    android:id="@+id/site_address"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:text="@string/site_address"
    android:textColorHint="#16a085"
    android:layout_marginTop="20dp"
    android:scaleType="centerInside"/>
</LinearLayout>

我把字体文件夹放在res。
  错误是 引起:java.lang.RuntimeException:原生字体无法制作
log cat:

        'at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
        at android.app.ActivityThread.access$1500(ActivityThread.java:117)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3687)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
        at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.NullPointerException
        at com.example.sali.package.MainListActivity.onCreate(MainListActivity.java:30)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)

1 个答案:

答案 0 :(得分:1)

您已将字体文件夹放在错误的目录中,正如您在问题中所述。在项目目录的根目录中创建一个名为assets的新文件夹,并将fonts文件夹放在那里。