我有一个带有 tabHost 的 fragmentActivity。每个 Tab 都有一个在屏幕上显示一些 ButtonTable 的片段。以下代码是 ButtonTable:
public class ButtonTable extends Button {
    private Paint paint= new Paint();
    private Bitmap bmp= null;
    private Table table= null;
    int width= 0;
    int height= 0;
    boolean adjustmentForm= false;
    private WeakReference<Bitmap> resizedBitmap;
    public ButtonTable(Context context, Table table, int width, int height) {
        super(context);
        this.table=table;
        this.width= width;
        this.height= height;
        setWidth(width);
        setHeight(height);
        setBitmapImage();
        setBackgroundColor(INVISIBLE);
    }
   [...]
    public void setBitmapImage(){
        int resurce= R.drawable.rectangle6;
     if(table.getTableType().equals("Circle6")){
         resurce=R.drawable.circle6;
         adjustmentForm= true;
        }
        if(table.getTableType().equals("Circle4")){
            resurce= R.drawable.circle4;
            adjustmentForm= true;
        }
        [...]
        bmp = BitmapFactory.decodeResource(getResources(), resurce);
        if(adjustmentForm){
            bmp = Bitmap.createScaledBitmap(bmp, height, height, true);
        }else{
            bmp = Bitmap.createScaledBitmap(bmp,width, height, true);
        }
        resizedBitmap = new WeakReference<Bitmap>(bmp);
    }
    @Override
    public void onDraw(Canvas canvas){
        super.onDraw(canvas);
        if(adjustmentForm){
         canvas.drawBitmap(resizedBitmap.get(), ((width-height)/2), 0, null);
         }else{
            canvas.drawBitmap(resizedBitmap.get(), 0, 0, null);
         }
    }
}
如果我在选项卡中移动一段时间,在大约 10/15 选项卡更改后,应用程序会因为 OutOfMemoryError 而停止。为什么?