2014-06-06 1 views
1

정보와 이미지를 Json (디코드)으로 URL에서 가져 와서 CustomListviewAdapter으로 표시하고 있지만 이해할 수없는 문제가 있습니다. 해결책을 찾지 못했습니다. 나는 어떤 오류 (내 에뮬레이터와 전화)도받지 못한다. 그러나 어떤 전화기는 bitmap size exceeds 32 bits error을주고있다. 내 앱이 Google Play 시장에 있기 때문에이 문제를 해결해야합니다.비트 맵 크기가 32 비트를 초과하는 일부 비트를 제공하는 안드로이드 장치가 있습니다.

그건 그렇고 urielageviewhelper 라이브러리를 사용하여 URL에서 이미지를 보여주고 게으른 로딩을 사용하고 있습니다. 당신이 나를 도울 수 있기를 바랍니다. 미리 감사드립니다. 여기

는 코드이다

@Override 
    protected void onPostExecute(String result) { 
     super.onPostExecute(result); 
     try { 

      JSONArray jsonResponse = new JSONArray(result); 
      asd = new String[3][jsonResponse.length()]; 
      rowItems = new ArrayList<RowItem>(); 

      for (int i = 0; i < jsonResponse.length(); i++) { 
       JSONObject js = jsonResponse.getJSONObject(i); 
       asd[0][i] = js.getString("Category_Name"); 
       asd[2][i] = js.getString("Image"); 
       asd[1][i] = js.getString("Term_ID"); 

       RowItem item = new RowItem(asd[2][i], asd[0][i], asd[1][i]); 
       rowItems.add(item); 
      } 


      adapter = new CustomListViewAdapter(MainActivity.this, 
        R.layout.list_item, rowItems); 

      listView.setAdapter(adapter); 



     } catch (JSONException e) { 
      e.printStackTrace(); 
     } 

    } 

} 

RowItem 클래스

public class RowItem<T> { 
private String imageId; 
private String title; 
private String desc; 

public RowItem(String imageId, String title, String desc) { 
    this.imageId = imageId; 
    this.title = title; 
    this.desc = desc; 
} 
public String getImageId() { 
    return imageId; 
} 
public void setImageId(String imageId) { 
    this.imageId = imageId; 
} 
public String getDesc() { 
    return desc; 
} 
public void setDesc(String desc) { 
    this.desc = desc; 
} 
public String getTitle() { 
    return title; 
} 
public void setTitle(String title) { 
    this.title = title; 
} 

@Override 
public String toString() { 
    return title + "\n" + desc; 
} 
} 

CustomListViewAdapter 클래스

public class CustomListViewAdapter extends ArrayAdapter<RowItem> { 
Context context; 
Boolean isInternetPresent = false; 
public CustomListViewAdapter(Context context, int resourceId, 
     List<RowItem> items) { 
    super(context, resourceId, items); 
    this.context = context; 
} 

/* private view holder class */ 
private class ViewHolder { 
    ImageView imageView; 
    TextView txtTitle; 
    TextView txtDesc; 
} 

public View getView(int position, View convertView, ViewGroup parent) { 
    ViewHolder holder = null; 
    RowItem rowItem = getItem(position); 

    LayoutInflater mInflater = (LayoutInflater) context 
      .getSystemService(Activity.LAYOUT_INFLATER_SERVICE); 
    if (convertView == null) { 
     convertView = mInflater.inflate(R.layout.list_item, null); 
     holder = new ViewHolder(); 
     holder.txtDesc = (TextView) convertView.findViewById(R.id.desc); 
     holder.txtTitle = (TextView) convertView.findViewById(R.id.title); 
     holder.imageView = (ImageView) convertView.findViewById(R.id.icon); 
     convertView.setTag(holder); 
    } else 
     holder = (ViewHolder) convertView.getTag(); 

    holder.txtTitle.setText(rowItem.getTitle()); 

    ImageView img = (ImageView) convertView.findViewById(R.id.icon); 
    ImageView gif = (ImageView) convertView.findViewById(R.id.icon); 

    Ion.with(gif).load("http://www.example.com/wp-content/uploads/2014/03/android-icon/loading.gif"); 
    Drawable drawable=gif.getDrawable(); 
    UrlImageViewHelper.setUrlDrawable(img, rowItem.getImageId(),drawable, 
      600000); 
    return convertView; 
} 
} 

오류 로그

java.lang.IllegalArgumentException: bitmap size exceeds 32bits 
at android.graphics.Bitmap.nativeCreate(Native Method) 
at android.graphics.Bitmap.createBitmap(Bitmap.java:809) 
at android.graphics.Bitmap.createBitmap(Bitmap.java:769) 
at android.view.View.buildDrawingCache(View.java:13649) 
at android.view.View.getDisplayList(View.java:13379) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.getDisplayList(View.java:13398) 
at android.view.View.getDisplayList(View.java:13445) 
at android.view.View.draw(View.java:14223) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3118) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2955) 
at android.view.View.draw(View.java:14509) 
at android.widget.FrameLayout.draw(FrameLayout.java:472) 
at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2452) 
at android.view.View.getDisplayList(View.java:13403) 
at android.view.View.getDisplayList(View.java:13445) 
at  android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1570) 
at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1449) 
at android.view.ViewRootImpl.draw(ViewRootImpl.java:2431) 
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2301) 
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931) 
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1047) 
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5896) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761) 
at android.view.Choreographer.doCallbacks(Choreographer.java:574) 
at android.view.Choreographer.doFrame(Choreographer.java:544) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747) 
at android.os.Handler.handleCallback(Handler.java:733) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5105) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:515) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608) 
at dalvik.system.NativeStart.main(Native Method) 
+1

내부'의 getView()''convertView.findViewById (R.id.icon)'가 – CodeWarrior

+0

을 rquired 아니에요, 두 번 결국 하나를 제거라는지고 감사합니다 매우를 많이 .. 내 관심을 앗아 갔어. – fthopkins

+1

그렇다면 내가 답변으로 게시하고 답변을 승인 할 수 있음을 알려주십시오. :) – CodeWarrior

답변

-1
try this : 

String imageUrl ="http://www.example.com/wp-content/uploads/2014/03/android- icon/loading.gif"; 
public static int calculateSampleSize(BitmapFactory.Options options, 
    int reqWidth, int reqHeight) { 
    // Raw height and width of image 
    final int height = options.outHeight; 
    final int width = options.outWidth; 
    int inSampleSize = 1; 

    if (height > reqHeight || width > reqWidth) { 

     // Calculate ratios of height and width to requested height and 
     // width 
     final int heightRatio = Math.round((float) height 
       /(float) reqHeight); 
     final int widthRatio = Math.round((float) width/(float) reqWidth); 

     // Choose the smallest ratio as inSampleSize value, this will 
     // guarantee 
     // a final image with both dimensions larger than or equal to the 
     // requested height and width. 
     inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; 
    } 

    return inSampleSize; 
} 





     InputStream in1 = convertURLtoInputStream(ImageUrl); 
    InputStream in2 =  convertURLtoInputStream(ImageUrl); 


     final BitmapFactory.Options options = new BitmapFactory.Options(); 
     options.inJustDecodeBounds = true; 

     BitmapFactory.decodeStream(in1, null, options); 
     options.inSampleSize = calculateSampleSize(options, imgWidth , imgHeight); 


    options.inJustDecodeBounds = false; 
    bitmap = BitmapFactory.decodeStream(in2, null, options); 
         bitmapList.add(bitmap); 
관련 문제