2012-02-15 1 views
0

이미지를 갤러리보기로로드하고 이미지를 스크롤하는 동안 흔들리는 일이 있거나 붙어있는 것처럼 보입니다. 부드러운 스크롤 갤러리가 있습니다. 이것은 10.1 Samsung Galaxy 태블릿에서 스크롤 할 때만 발생합니다. 이 문제를 해결하도록 도와주세요.갤러리 스크롤링이 부드럽지 않고 태블릿에서 스크롤하는 동안 흔들리는 일종입니다.

내가

@Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     final int pos = position; 
     View retval = LayoutInflater.from(parent.getContext()).inflate(
       R.layout.horrizontallistitem, null); 
     final ImageView imgitem = (ImageView) retval 
       .findViewById(R.id.hlvItem); 
     try { 
      imgitem.setImageBitmap(CommonKeys 
        .getBitmapFromAsset("_images/" + dataObjects[pos] 
          + ".png")); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 

     } 
     return retval; 
    } 
+0

이것은 타블렛에서만 발생하며 다른 전화기에서는 발생하지 않습니까? – Maurice

+0

예, 태블릿에서만 발생합니다. – cavallo

답변

0

공용 클래스 LazyAdapter가 BaseAdapter를 확장하는 아래의 코드를 사용 {

private Activity activity; 
private String[] data; 
private static LayoutInflater inflater=null; 
public ImageLoader imageLoader; 

public LazyAdapter(Activity a, String[] d) { 
    activity = a; 
    data=d; 
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    imageLoader=new ImageLoader(activity.getApplicationContext()); 
} 

public int getCount() { 
    return data.length; 
} 

public Object getItem(int position) { 
    return position; 
} 

public long getItemId(int position) { 
    return position; 
} 

public View getView(int position, View convertView, ViewGroup parent) { 

    final int pos = position; 
    final ImageView imgitem=null; 
    View retval = convertView; 
    if(retval==null) 
    { 
      retval = LayoutInflater.from(parent.getContext()).inflate(
         R.layout.horrizontallistitem, null); 
      imgitem = (ImageView) retval 
         .findViewById(R.id.hlvItem); 
    } 
    imageLoader.DisplayImage(dataObjects[position], imgitem); 
    return retVal; 
} 

는 아래 링크로 게으른 어댑터 implmentation 참조 :이 FileCache에서 https://github.com/thest1/LazyList/tree/master/src/com/fedorvlasov/lazylist

, UrlConnection 코드는 당신에게 유용하지 않습니다. 나머지 코드는 타겟을 달성 할 수 있습니다.

0
Create Image View at run time and add to Gallery.Your Activity Should implements 
ViewFactory  

private class ImageAdapter extends BaseAdapter{ 
    Context mContext; 
    private int itemBackground; 

    //private LayoutInflater layoutInflater; 
    public ImageAdapter(Context c){ 
     mContext = c; 
     //tempBitmap.clear(); 
     //tempBitmap=hashMap.get("page"+pageCount); 
     tempbitmap=new ArrayList<Bitmap>(); 
     tempbitmap.clear(); 
     int end=pageCount*5; 
     int start=end-5; 
     tempbitmap=bitmapArray.subList(start, end); 
     TypedArray attr = obtainStyledAttributes(R.styleable.HelloGallery); 
     itemBackground = attr.getResourceId(
       R.styleable.HelloGallery_android_galleryItemBackground, 0); 
     attr.recycle();  
     //layoutInflater = LayoutInflater.from(c); 
    } 

     @Override 
     public int getCount() { 
      // TODO Auto-generated method stub 
      return tempbitmap.size(); 
     } 

     @Override 
     public View getView(int position, View convertView, ViewGroup arg2) { 
      // TODO Auto-generated method stub 

      ImageView imageView; 
      if (convertView == null) { // if it's not recycled, initialize some attributes 
       imageView = new ImageView(mContext); 
       imageView.setLayoutParams(new Gallery.LayoutParams(170,grid_main.getHeight())); 
       imageView.setScaleType(ImageView.ScaleType.FIT_XY); 
       imageView.setBackgroundResource(itemBackground); 

       //imageView.setPadding(8,8,8,8); 
      } else { 
       imageView = (ImageView) convertView; 
      } 
      imageView.setImageBitmap(tempbitmap.get(position)); 
      return imageView; 
     } 

     @Override 
     public Object getItem(int position) { 
      // TODO Auto-generated method stub 
      return null; 
     } 

     @Override 
     public long getItemId(int position) { 
      // TODO Auto-generated method stub 
      return 0; 

     } 

     } 


    @Override 
    public View makeView() { 
     // TODO Auto-generated method stub 
     ImageView imageView = new ImageView(this); 
     imageView.setScaleType(ImageView.ScaleType.FIT_CENTER); 
     imageView.setLayoutParams(new 
       ImageSwitcher.LayoutParams(
         LayoutParams.FILL_PARENT, 
         LayoutParams.FILL_PARENT)); 
     imageView.setBackgroundColor(0xFF000000); 
     return imageView; 
    } 
관련 문제