我試圖建立一個警告對話框,使用下面的代碼,但應用程序崩潰保持在這一點上。任何明顯的錯誤?下面alertdialog導致內存錯誤
AlertDialog alertDialog = new AlertDialog.Builder(
Crossword1.this).create();
alertDialog.setTitle("Well done, the crossword is complete!");
alertDialog.setMessage("well done cuz");
alertDialog.setIcon(R.drawable.tick);
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
logcat中,提到內存雖然我不明白爲什麼alertdialog箱應引起內存錯誤(如果alertdialog被註釋掉的應用程序運行正常)
12-21 17:57:33.180: D/BounceScrollRunnableDefault(24966): start(1554.2593), mBounceExtent:0.0
12-21 17:57:33.180: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -205.16223
12-21 17:57:34.335: D/BounceScrollRunnableDefault(24966): start(0.0), mBounceExtent:-11.0
12-21 17:57:34.335: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -11.0
12-21 17:57:34.555: D/BounceScrollRunnableDefault(24966): start(0.0), mBounceExtent:-19.245642
12-21 17:57:34.555: D/BounceScrollRunnableDefault(24966): mBounceExtentCoef = -19.245642
12-21 17:57:35.505: I/dalvikvm-heap(24966): Clamp target GC heap from 65.159MB to 64.000MB
12-21 17:57:35.505: D/dalvikvm(24966): GC_FOR_ALLOC freed 580K, 2% free 64467K/65479K, paused 20ms
12-21 17:57:35.505: I/dalvikvm-heap(24966): Forcing collection of SoftReferences for 2903056-byte allocation
12-21 17:57:35.545: I/dalvikvm-heap(24966): Clamp target GC heap from 65.151MB to 64.000MB
12-21 17:57:35.545: D/dalvikvm(24966): GC_BEFORE_OOM freed 9K, 2% free 64458K/65479K, paused 27ms
12-21 17:57:35.545: E/dalvikvm-heap(24966): Out of memory on a 2903056-byte allocation.
請發表您的logcat的錯誤! –
道歉,增加上面 – Kurt
你正在超出內存異常(最後一行日誌)。除非您使用的圖標是一個巨大的文件,否則您的警報對話框與它無關。 –