这是我使用的代码,库从jar中导入,图像链接工作正常,我甚至在AndroidManifest.xml中添加了Internet权限。 问题是,当我启动应用程序时,它会打开并关闭而不显示任何内容。毕加索不会显示imgur的图像
package my.pkg.name;
import com.squareup.picasso.*;
import android.R.id.*;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.id.immagine);
ImageView targetImageView = (ImageView) findViewById(R.id.immagine);
String internetUrl = "http://i.imgur.com/DvpvklR.png";
Picasso
.with(this)
.load(internetUrl)
.into(targetImageView);
}
}
这是布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="just a string"
/>
<ImageView
android:id="@+id/immagine"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:contentDescription="213"
/>
</LinearLayout>
谢谢
使用LogCat检查与您的崩溃相关的Java堆栈跟踪:https://stackoverflow.com/questions/23353173/uncomfort-myapp-has-stopped-how-can-i-solve-this – CommonsWare
您可以发布您的堆栈跟踪以及? :) –
@CommonsWare它真的看起来不像崩溃,这很可能是代码中的错误。感谢您的回答,尽管 –