2017-03-06 14 views
1

最初にデータが正しく取り込まれます。しかし、私が下から上にスクロールすると、すべてのデータとその位置が乱されます。私は itemViewHolder.setIsRecyclable(false); setHasStableIds(false)を追加しようとした誰かがplsはお勧めできることは何もリサイクル業者のスクロールに関するRecyclerviewインデックス位置の混乱データ

public HomeRecyclerViewAdapter(Context context, Home homeModel) { 
     this.context = context; 
     this.homeModel = homeModel; 
    } 
@Override 
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { 

     if (viewType == TYPE_HEADER) { 
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.homefragment_header, parent, false); 
      return new HeaderViewHolder(v); 
     } else if (viewType == TYPE_ITEM) { 
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_homefragment, parent, false); 
      return new ItemViewHolder(v); 
     } else if (viewType == PRODUCT_ITEM) { 
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_productlines, parent, false); 
      return new ProductLinesItemHolder(v); 
     } else if (viewType == SHOPS_ITEM) { 
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.layout_productlines, parent, false); 
      return new ShopsOfWeekItemHolder(v); 
     } 
     return null; 
    } 
@Override 
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { 
     if (position == 0) { 
      if (holder instanceof HeaderViewHolder) { 
       // load data in slider 
      } 
     } else if (holder instanceof ItemViewHolder) { 
      ItemViewHolder itemViewHolder = (ItemViewHolder) holder; 
      if (homeModel.getCategories().get(0) != null) { 
       if (position == 1) { 
        //load data in category recyclerview 
        holder.setIsRecyclable(false); 
       } 
      } 
     } else if (holder instanceof ProductLinesItemHolder) { 
      ProductLinesItemHolder itemViewHolder = (ProductLinesItemHolder) holder; 
      if (homeModel.getProductLines() != null) { 
       if (position > 1 && pos <= homeModel.getProductLines().size()-1) { 
        Log.d("HomeRecycler","pos:"+pos); 
        Log.d("HomeRecycler","position:"+ (position-2)); 
         setRecyclerView(2, itemViewHolder); 
         Log.d("HomeRecycler","pos:"+homeModel.getProductLines().get(pos).getName()); 
         itemViewHolder.txtProductName.setText(homeModel.getProductLines().get(pos).getName()); 
         itemViewHolder.txtViewAllShops.setVisibility(View.GONE); 
         populateProductLinesItem(itemViewHolder, homeModel.getProductLines().get(pos)); 
         pos = pos + 1; 

       } 
      } 
     } 
private void populateProductLinesItem(ProductLinesItemHolder itemViewHolder, ProductLines productLines) { 
     ProductLinesItemAdapter productLinesItemAdapter = new ProductLinesItemAdapter(context, productLines.getItems(), clickEventOfProductsItemListener); 
     itemViewHolder.prodLinesRecyclerView.setAdapter(productLinesItemAdapter); 
     productLinesItemAdapter.notifyDataSetChanged(); 
    } 

水平recyclerviewを投入しようとしている垂直recyclerview内部 を働きません?この問題を避けるには? もっとコード:これに基づきhttps://gist.github.com/anonymous/7785cdd97b5c27886c81f321c8965930

答えて

0

しかし、私は、すべてのデータとその位置めちゃめちゃを下から上にrecyclerviewをスクロールします。

同様の問題がありました。ここにはSO Postがあります。

関連する問題