我试图在显示启动画面时从Internet中读取17个图像。但是,使用以下代码,在处理过程中根本不会显示启动画面。它变黑,完成并转移到下一个活动。我认为在处理代码足够好之前调用setContentView,但显然不是。Android UI在处理其他数据时未显示
我错过了什么?
感谢您的帮助。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
// read the bitmaps
// Open a new URL and get the InputStream to load data from it
// Start reading the XML and filling the arrays
for (int i=0; i<16; i++) {
try {
URL aURL = new URL (districtImage[i]);
URLConnection conn = aURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
// Buffered is always good for performance
BufferedInputStream bis = new BufferedInputStream(is);
districtBitmap[i] = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
}
catch (IOException e){
Log.e ("DEBUGTAG","Cannot load remote image", e);
}
}
... some more code to transit to next activity...
}
感谢您的快速回复。让我看看并回来。 – MikeC 2011-04-13 15:01:43
通读AsyncTask。这是要走的路。谢谢 – MikeC 2011-04-14 02:29:20