我使用GridList開發android片段有許多圖像項目。當開始到這個片段時,暫停屏幕並緩慢啓動。此外,當多次(約3次)開始這個片段,應用程序被殺害。Android應用程序因爲許多圖像而死亡
代碼:
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_tiro_com_arco), "Archery"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_ginastica_artistica), "Artistic Gymnastics"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_atletismo), "Athletics"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_badminton), "Badminton"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_basquetebol), "Basketball"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_volei_de_praia), "Beach Volleyball"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_ciclismo_bmx), "BMX Cycling"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_boxe), "Boxing"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_canoagem_slalom), "Canoe/Kayak Slalom"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_canoagem_velocidade), "Canoe/Kayak Sprint"));
mGridArray.add(new GridViewItem(getBitmap(R.drawable.rio2016_sports_pictogram_olympic_saltos_ornamentais), "Diving"));
(有許多行以同樣的方式同上。)
反正我能嘗試這種現象呢?你有我提到的文件或代碼嗎?
我是Android的初學者。所以我的問題似乎很容易。但如果你給我答案,我真的很感激它。謝謝:)
圖像有多大? Android不允許應用程序使用大量的堆。 https://developer.android.com/training/articles/memory.html – Knossos
如何處理位圖操作的最佳參考是在tha API中:http://developer.android.com/training/displaying-bitmaps/index.html – Opiatefuchs
使用下面的庫來顯示圖像: https://github.com/nostra13/Android-Universal-Image-Loader –