0

我遇到了这个奇怪的错误,我的应用程序在没有错误消息或强制关闭的情况下退出,除了这个:“致命信号 11 (SIGSEGV) at 0x00000000 (code=1)”

它突然发生了,我找不到问题......我的代码

主要活动

package com.example.newyorkfinal;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity implements OnClickListener {

    TextView navTitle;
    Button aboutButton,themeNightButton;
    Intent startIntent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        aboutButton = (Button) findViewById(R.id.buttonAbout);
        themeNightButton = (Button) findViewById(R.id.buttonThemeNights);

        Typeface orangeTypeFace = Typeface.createFromAsset(getAssets(), "fonts/ORANGE JUICE.TTF"); 



        navTitle = (TextView) findViewById(R.id.navigationTitle);
        navTitle.setTypeface(orangeTypeFace);

        aboutButton.setOnClickListener(this);
        themeNightButton.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    public void onClick(View v){

        switch (v.getId()) {
        case R.id.buttonAbout :{
            startIntent = new Intent(this,About.class);
            startActivity(startIntent);
            break;
        }
        case R.id.buttonThemeNights :{
            startIntent = new Intent(this,themesActivity.class);
            startActivity(startIntent);
            break;
        }

        }
    }



}

关于.java

package com.example.newyorkfinal;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;

public class About extends Activity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.about_layout);



    }

}
4

1 回答 1

0

问题是从资产加载字体

执行以下操作以解决此问题

用 try/catch 包围这条线

 try{
    Typeface orangeTypeFace = Typeface.createFromAsset(getAssets(), "fonts/ORANGE_JUICE.TTF");
 }catch(Exception e){
 }

像这样重命名您的 ttf,因为您的 ttf 文件包含空格

用ORANGE_JUICE.TTF重命名ORANGE JUICE.TTF

于 2013-09-09T11:06:28.837 回答