2012-12-16 2 views
2

트위터 목록에서 프로필 이미지를 표시하려고합니다. 비동기 작업에 listview가 사용되었습니다. 내 ImageView는 URL의 드로어 블에서 동적으로 수행됩니다. 2.3.3에서는 제대로 작동하는 것으로 보이지만 이미지는 4.0에 표시되지 않습니다. ImageView는 4.0에서 작동해야합니다. 나는 당혹 스럽다.ImageView가 ListView Android 4.0에 표시되지 않습니다.

Tweet o = tweets.get(position); 
       Drawable drawable = LoadImageFromUrl.LoadImageFromWebOperations(o.profile_image_url); 
       image.setImageDrawable(drawable); 

당김을 URL로 변환하는 방법은 이것이다 : 여기 내 어댑터에서 내 목록 항목 (트윗)에 대한

public static Drawable LoadImageFromWebOperations(String url) { 
     try { 
      Log.i("URL", url); 
      InputStream is = (InputStream) new URL(url).getContent(); 
      Drawable d = Drawable.createFromStream(is, "src name"); 
      return d; 
     } catch (Exception e) { 
      return null; 
     } 
    } 

그리고 내 XML 레이아웃은 여기에 있습니다 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:orientation="vertical" 
android:padding="8dip" xmlns:android="http://schemas.android.com/apk/res/android"> 

<ImageView 
    android:id="@+id/profile_image" 
    android:layout_width="48dip" 
    android:layout_height="48dip" 
    android:layout_gravity="top|left" 
    android:layout_margin="6dip" 
    android:contentDescription="Profile Image" 
    android:src="@drawable/ic_launcher"/> 

<!-- Name --> 
<TextView 
    android:id="@+id/name" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/profile_image" 
    android:paddingBottom="1dip" 
    android:textColor="#0598DD" 
    android:textSize="14dip" 
    android:textStyle="bold" /> 

<!-- Screen name --> 
<TextView 
    android:id="@+id/screen_name" 
    android:layout_below="@id/profile_image" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_toRightOf="@+id/name" 
    android:paddingBottom="1dip" 
    android:textColor="#ffffff" 
    android:textSize="14dip" 
    android:textStyle="italic" /> 

<!-- Tweet --> 
<TextView 
    android:id="@+id/text" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/name" 
    android:paddingBottom="1dip" 
    android:textColor="#ffffff" 
    android:textSize="16dip" 
    android:textStyle="bold" /> 

<!-- date --> 

<TextView 
    android:id="@+id/time_stamp" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/text" 
    android:paddingBottom="3dip" 
    android:textColor="#0598DD" 
    android:textSize="14dip" 
    android:textStyle="italic" /> 
</RelativeLayout> 

답변

0

아무도 응답하지 않았습니다. UrlImageViewHelper를 사용하여이 문제를 해결했습니다.

UrlImageViewHelper.setUrlDrawable(image, o.profile_image_url); 
관련 문제