2012-07-06 64 views
1

我正在加載大約100個小聲音的聲音庫,我需要它們通過應用程序進行活動。 當此活動啓動時,屏幕將變爲空白,並在加載所有聲音庫後加載背景。加載音柱時,活動屏幕變爲空白

如何使顯示已加入聲音庫時已添加到xml中的背景I?

回答

4

使用AsyncTask來處理這個問題。

private class MyBackgroundTask extends AsyncTask<String, Void, Boolean> { 

    @Override 
    protected void onPreExecute() { 
     //initialize views like progress dialog. 
    } 

    @Override 
    protected Boolean doInBackground(String... params) { 
     //Add code which you want to run in background. 
     //In your case, code to load sound pools 
    } 

    @Override 
    public void onPostExecute(Boolean success) { 
     //update UI with the result 
    } 
} 

而且在onCreate方法,

new MyBackgroundTask().execute(); 
+1

讓我知道如果你仍然在使用這種後面臨的問題.. – 2012-07-06 13:39:54

+0

謝謝你的回覆。 :) 我會盡力實現它,並回到這裏。 意思是,如果可以給我任何關於AsyncTask的例子的鏈接會幫助我很多。 – Aadi 2012-07-07 05:41:09

+1

看看這個http://www.vogella.com/articles/AndroidPerformance/article.html#asynctask – 2012-07-09 04:52:15