可以asyncronously使用AsyncTask
只需要將相關的圖像加載代碼中doInBackground方法 加載圖像並嘗試設置就像一個進度條或進度對話框 的指標,所以你會開始示出的對話框或杆在裝載 的開頭和結束後駁回利用處理程序的對話框中onPostExecute方法
樣品代碼:
class SomeClass extends Activity {
protected ProgressDialog pd ;
protected Handler handler = new Handler(){
@Override
public void handleMessage(int what){
if(pd.isShowing())
pd.dismiss();
}
.....
class LoadImageTask extends AsyncTask<URL, Integer, Long> {
protected void onPreExecute(Long result) {
pd = ProgressDialog.show(getContext(),"Title","Message");
}
protected Long doInBackground(URL... urls) {
//Load IMAGEs code
return totalSize;
}
protected void onPostExecute(Long result) {
//finish loadiing images
handler .sendEmptyMessage(0);
}
}
}
我希望這會幫助你
也許我沒有完全理解這個問題,但是你可以在一個單獨的線程上運行你的進程,然後跳回到主要更新UI? –
問題似乎是加載圖像需要多長時間。定時器保持打勾狀態,因爲它需要。 Uri正在被大量時間解決,但設定圖像似乎需要很長時間。在崩潰之前,它通過的300個圖像URI只顯示一個或兩個圖像。此外ImageViews在UI工具包存在,並且根據文件,我們不能觸摸它的主線程之外。 – Mytheral