2016-07-12 2 views
0

현재 ImageViews를 추가하고 ViewHolder 내에 이미지를 설정하고 있습니다. 생성 시간이 매끄럽지 않고 첫 번째 스크롤이 원활하지 않습니다. 뷰어 홀더 내에서 부드러운 동적 뷰를 갖는 것에 대한 제안이나 대안? 그들이보기에없는 경우ViewHolder RecyclerView 어댑터 내부에서 동적 뷰를 추가하는 방법

ViewHolder

class ViewHolderRecipientExpanded extends RecyclerView.ViewHolder { 
    private LinearLayout mFlagLayout; 
    // 

    public ViewHolderRecipientExpanded(View v) { 
     super(v); 
     mFlagLayout = (LinearLayout) v.findViewById(R.id.flagLayout); 
     // 
    } 

    public void initiateRecipientsDetails() { 
     Recipient recipient = objectList.get(getAdapterPosition()); 
     int totalAmountOfCountries = recipient.getFlags() != null ? recipient.getFlags().size() : 0; 
     // 
     int countriesLimitedToThree = recipient.getFlags() != null ? (totalAmountOfCountries > 3 ? 3 : totalAmountOfCountries) : 0; 
     View imageView; 
     ImageView image; 
     Drawable drawable; 
     for (int i = 0; i < countriesLimitedToThree; i++) { 
      imageView = inflater.inflate(R.layout.view_image_flag, null); 
      image = (ImageView) imageView.findViewById(R.id.image); 
      drawable = new BitmapDrawable(context.getResources(), recipient.getFlags().get(i).getFlag()); 
      image.setImageDrawable(drawable); 
      mFlagLayout.addView(imageView); 
     } 
    } 
} 

답변

0

는 이미지 asynchronouslycache them in memory를로드합니다. 이렇게하면 이미지를로드 할 때 UI 스레드가 차단되지 않으므로 이미지가 아직로드되지 않은 경우에도 사용자가 스크롤 할 수 있습니다. 이미지가 실제로 나타나려면 아직 시간이 걸릴 것입니다.

:

는 또한 당신을 위해 이것을 처리 할 좋은 라이브러리가 있습니다

관련 문제