我正在写一个应用程序,它加载从URL,并显示在ImageView的图片。 这里是code ...
I'm writing an app which loads a picture from a URL and display in an imageview. here is the code...
public class MainActivity extends Activity {
private Picasso picasso;
private OkHttpClient okHttpClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView imageview = (ImageView) findViewById(R.id.imageView);
String image_url ="https://m.xsw88.com/allimgs/daicuo/20230913/803.png.jpg";
okHttpClient = new OkHttpClient();
picasso = new Picasso.Builder(this)
.downloader(new OkHttpDownloader(okHttpClient))
.build();
Context con = getApplicationContext();
picasso.with(con)
.load(image_url)
.placeholder(R.drawable.ic_launcher)
.resize(60,60)
.into(imageview);
}
该应用程序不会崩溃,但它并不显示照片无论是!在LogCat中我已经得到了这2个错误:
The app doesn't crash but it does not show the picture either! in the LogCat i've got these 2 errors:
09-15 13:17:17.419 2358-2358/**************** E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from GradienCache
09-15 13:17:17.439 2358-2358/**************** E/OpenGLRenderer﹕ Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
我使用Genymotion 2.0.1。 u能plz帮助我吗?
I'm using Genymotion 2.0.1 . Can u plz help me???
我终于加入正确的JAR文件固定的code!请确保您有这些库:
I finally fixed the code by adding correct JAR Files! Please make sure that you have these libraries:
1 OKHTTP-2.0.0
1- OKHTTP-2.0.0
2 - OKHTTP-的URLConnection-2.0.0(不RC1版本!)
2- OKHTTP-urlconnection-2.0.0 (not RC1 version!)
3奥基奥-1.0.1
3- Okio-1.0.1
4-毕加索-2.3.4
4- picasso-2.3.4
如果你使用这些库,GradienCache错误将被处理为异常,你就没有更多的得到强制关闭!
if you use these libraries, GradienCache Error will be handled as an exception and you'll no more get force close!
上一篇:如何与&lt添加自定义字段;消息> XMPP节/包的内容是什么?自定义、字段、消息、内容
下一篇:CMUSphinx PocketSphinx - 承认所有(或大量)的英文单词英文单词、CMUSphinx、PocketSphinx