Problem Description
Throw an exception android.os.NetworkOnMainThreadException
problem causes
In Android 4.0 and above, the network connection method execute() cannot be placed on the main thread, otherwise the exception android.os.NetworkOnMainThreadException will be thrown. But the version under 4.0 may not report an error.
solution
Create a new thread for network requests, directly use the anonymous inner class to create a new thread
// 新开用于网络请求的线程
new Thread(new Runnable(){
@Override
public void run() {
cachedImage = asyncImageLoader.loadDrawable(imageUrl, position);
imageView.setImageDrawable(cachedImage);
}
}).start();