您可以使用 AsyncTask 在后台填充列表,然后在加载完成后通知自己。
class MyTask extends AsyncTask<Context, Integer, String> {
m_loaded = false;
@Override
protected String doInBackground(Context... params) {
Log.d("doinBackground", "here");
// do your loading
return "";
}
// -- gets called just before thread begins
@Override
protected void onPreExecute() {
super.onPreExecute();
}
// -- called as soon as doInBackground method completes
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
m_loaded = true; //your list is done loading
}
}