Loaded in a listview list pictures, I began to do so, the use of a picture to create a thread to load, and then through the picture to load the address into a map as a key to control such collection in the same picture did not After loading when creating a thread again, but this way the question came. When I flick the list when this child will load some new pictures of different addresses, but before loading the picture thread has not yet been loaded, like this how could you not finished loading the thread stops away.<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Very good, very strong
Reply:
So too do the CPU and memory consumption,
Average load listView picture a thread on it
Like this.
new Thread () {
public void run () {
for (String url: imgURLs) {
Bitmap bitmap = downloadImage (url);
if (bitmap! = null) {
_map.put (url, bitmap); / / do this cache, downloaded would not have to download it.
/ / Ui thread update pictures to ListView
Message msg = new Message ();
msg.what = 1;
msg.obj = bitmap;
handler.sendMessage (msg);
}
}
}
.} Start ();
Reply:
On the second floor of a friend just like you open a thread, it is a normal screen can display 6-8 data like this, it is equivalent to other pictures, such as loading a paternity to be in a state loaded, so a a load will not.
My main problem regardless of open several threads are good, continue to drag the list or a list of words quickly how to solve drag when loading new data how to deal with those who did not finish the thread execution.
Reply:
Thread can not stop immediately when the JVM garbage there is a process, if ever create such APP thread easy consumption, memory consumption.
Personally think that a thread or two threads enough. Unless otherwise generally poor network environment or quickly get to the picture content.
To stop calling thread can only mandatory stop method to increase flag. But can not stop immediately.
No comments:
Post a Comment