0

"지연 이미지 로더"를 통해 이미지 뷰에 대화 상자에 이미지를로드하려고합니다. 내가 호출하는 방법을 보여주기 위해 두 개의 코드 스 니펫을 포함했습니다.대화 상자에 이미지 및 디스플레이 다운로드


---- 편집 -----

이제 보편적 인 이미지 로더 1.8.6

Log.i(Utils.TAG, "Show Photo"); 
ImageLoader imgLoader = new ImageLoader(a); 
imgLoader.DisplayImage(strUrl, image); 

을 @TalhaQ 방법 didn를하기 때문에 내가 그것을 전화 했어 방법이 있습니다 사용 ' 일하지 마라. 내가 그 URL로 이동 때 PARAMATERS


---- 원본과 동일한 수를 허용하지 않았다 --- 로그 고양이는 유효한 URL과 이미지를 보여줍니다. 어떤 아이디어?

Utils.java

public Dialog openFeed(final Activity a, final long id) { 

    final Dialog dialog = new Dialog(a); 
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); 
    dialog.getWindow().getAttributes().windowAnimations = R.style.dialog_animation; 
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    dialog.setContentView(R.layout.feed_item); 


    //Set the Title & Descr to the Item Selected 
    TextView title = (TextView) dialog.findViewById(R.id.txtItemTitle); 
    title.setText(strTitle); 

    TextView descr = (TextView) dialog.findViewById(R.id.txtItemDescription); 
    descr.setText(strDescr); 

    ImageView image = (ImageView) dialog.findViewById(R.id.imgFeedImage); 


    Log.i(TAG, "strUrl: " + a.getResources().getString(R.string.photoURL) + strUrl); 

    ImageLoader imageLoader = new ImageLoader(a); 
    imageLoader.DisplayImage(a.getResources().getString(R.string.photoURL) + strUrl, image); 

    Button CommentButton = (Button) dialog.findViewById(R.id.dialogButtonComment); 

    // if button is clicked, close the custom dialog 
    CommentButton.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      dialog.dismiss(); 

      final AlertDialog addComment = Utils.openComments(a, id); 
      addComment.show(); 
     } 
    }); 

XML : 나는 또한 제대로 컨텍스트를 통과하지 생각 Loader.I 같은 게으른 이미지를 사용하고

<ImageView 
    android:id="@+id/imgFeedImage" 
    android:layout_width="wrap_content" 
    android:layout_height="200dp" 
    android:layout_alignLeft="@+id/txtItemDescription" 
    android:layout_alignRight="@+id/txtItemDescription" 
    android:layout_below="@+id/txtItemDescription" 
    android:contentDescription="@string/itemicon" 
    android:src="@drawable/gplus" 
    android:scaleType="fitCenter" 
    android:maxHeight="200dp" 
    android:visibility="invisible" /> 
+0

당신이 당신의 로그 고양이 오류를 게시 할 수있는 활동 runOnUiThread()과 유사, UI 스레드의 메시지 큐에 Runnable를 게시하려면? –

+0

로그캣 오류가 없습니다. 단지 이미지를 다운로드하고 표시하지 않습니다. – jcaruso

답변

1

.

int loader = R.drawable.loader;//Old image in the imageview 
    ImageLoader imgLoader = new ImageLoader(ctx); // ctx is the context 
    imgLoader.DisplayImage(image_url, loader, image);//image is the imageview,image_url is the url to image 

체크 아웃 내 output.If 당신은 아직도 당신이 아래의 시나리오보다 대화 상자에서 이미지를로드 할 때 내가 link

enter image description here

+0

ImageLoader 유형의 DisplayImage (String, ImageView) 메서드는 인수 (String, int, ImageView)에 적용 할 수 없습니다. – jcaruso

+0

어떤 Lazy 이미지 로더를 사용하고 있는지 알려주실 수 있습니까? 그러면 샘플을 생성 해 드리겠습니다. –

+0

당신의 사용법과 사용 방법을 알려주십시오 – jcaruso

0

에서 내 sample.Download it.Check를 부착하고 어떤 도움을 필요로 다운로드 된 이미지에서 발생하므로 ClassCastException을 처리해야합니다. 코드 아래의 이미지 로더가 도움이 될 것입니다. 이미지 뷰가 당신은 컨텍스트가 활동에 캐스트 할 수 있습니다지지 않습니다 활동

Activity a= (Activity)(photoToLoad.imageView.getContext()); 

내부 조각이나 활동 또는 이미지 뷰에로드 목록 안에있는 경우 그 예외가되지 발생합니다. 따라서 예외 : 사실 ContextThemeWrapper 인 Context를 Activity로 캐스팅하려고합니다.

당신은 예와

Activity a= (Activity)(photoToLoad.imageView.getContext()); 
a.runOnUiThread(bd); 

을 대체 할 수

photoToLoad.imageView.post(bd);