我正在嘗試使用Picasso API for Android Studio Java從URL下載圖像。單擊浮動操作欄並顯示一個警報對話框,其中包含URL中的圖像。Picasso目標空URL文件下載錯誤。 Java
我試過以下: Picasso Target must not be null error。 但我的錯誤仍在發生。
這是代碼我目前使用:
FloatingActionButton FabViewImage = (FloatingActionButton) findViewById(R.id.fabPicture);
if (FabViewImage != null)
FabViewImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Dialog settingsDialog = new Dialog(TabEmpOrder.this);
settingsDialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
settingsDialog.setContentView(getLayoutInflater().inflate(R.layout.order_detail_image_view, null));
Context context = settingsDialog.getContext();
settingsDialog.show();
ImageView imgView = (ImageView) findViewById(R.id.imgOrderDetails);
Picasso.with(context).load("http://i.imgur.com/Tnendik.png").into(imgView);
}
});
下面是它顯示
08-23 09:54:06.351 25488-25488/dura_art.bigbyte E/AndroidRuntime: FATAL EXCEPTION: main
Process: dura_art.bigbyte, PID: 25488
java.lang.IllegalArgumentException: Target must not be null.
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:618)
at com.squareup.picasso.RequestCreator.into(RequestCreator.java:601)
at dura_art.bigbyte.TabEmpOrder$1.onClick(TabEmpOrder.java:99)//This is where it breaks
at android.view.View.performClick(View.java:5697)
at android.view.View$PerformClick.run(View.java:22526)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
我有什麼錯的錯誤信息?我該如何解決它?
在onCreate中初始化您的ImageView並確保R.id.imgOrderDetails確實指向相同的視圖。 –
因此您的圖像顯示在警報對話框中?圖像視圖對話框佈局的一部分? – himanshu1496