我的网址:http://www.deepanelango.me/wp%2Dcontent/uploads/2017/06/noyyal1.jpg
如何从上面提到的网址获取图片并将其设置在android的imageview中? 我试过滑行,这是我的错误日志:
I / Glide:根本原因(1 of 1) java.net.SocketTimeoutException:连接超时 at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196) 在java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178) 在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356) 在java.net.Socket.connect(Socket.java:605) 在com.android.okhttp.internal.Platform.connectSocket(Platform.java:113) 在com.android.okhttp.Connection.connectSocket(Connection.java:196) 在com.android.okhttp.Connection.connect(Connection.java:172) 在com.android.okhttp.Connection.connectAndSetOwner(Connection.java:367) 在com.android.okhttp.OkHttpClient $ 1.connectAndSetOwner(OkHttpClient.java:130) 在com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) 在com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:247) 在com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457) 在com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126) 在com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102) 在com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:54) at com.bumptech.glide.load.model.MultiModelLoader $ MultiFetcher.loadData(MultiModelLoader.java:96) 在com.bumptech.glide.load.model.MultiModelLoader $ MultiFetcher.startNextOrFail(MultiModelLoader.java:147) at com.bumptech.glide.load.model.MultiModelLoader $ MultiFetcher.onLoadFailed(MultiModelLoader.java:141) 在com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:60) at com.bumptech.glide.load.model.MultiModelLoader $ MultiFetcher.loadData(MultiModelLoader.java:96) 在com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61) 在com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298) 在com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:268) 在com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607) 在java.lang.Thread.run(Thread.java:761) 在com.bumptech.glide.load.engine.executor.GlideExecutor $ DefaultThreadFactory $ 1.run(GlideExecutor.java:413)
答案 0 :(得分:0)
使用Picasso库
Picasso.with(context)
.load(ImageURL)
.into(imageView);
答案 1 :(得分:0)
添加依赖
compile 'com.github.bumptech.glide:glide:3.8.0'
和
Glide.with(yourContext).load(Your Url).into(imageview);
答案 2 :(得分:0)
如果只是静态图片,请下载并将其添加到您的应用资源中。
如果您有多个非静态图像,那么最好使用Glide库,因为它会处理下载,缓存等等。