這是我使用的代碼,庫從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它真的看起來不像崩潰,這很可能是代碼中的錯誤。感謝您的回答,儘管 –