Android addView导致崩溃而没有任何日志

时间:2013-05-28 00:03:53

标签: android android-layout textview typeface

当我调用addView大约80次时,app会自动关闭,我该如何解决?

MainActivity

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LinearLayout l = new LinearLayout(this);
        for (int i = 0; i < 80; i++)
            l.addView(new MyTextView(this));
        setContentView(l);
    }

MyTextView

public class MyTextView extends TextView {

    public MyTextView(Context context) {
        super(context);
        // TODO Auto-generated constructor stub
        setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/default.ttf"));
        setTextSize(20);
    }
}

0 个答案:

没有答案