简体   繁体   中英

Using view pager in recycler view row?

In my app, I am using a fragment view pager in my recycler view rows. I am doing this to display the main content in the first fragment and then a fragment container a delete button as the second fragment. For some reason, when I launch my app, my view pager is only working in the first row. Does anyone know what could be causing this? I have tried using multiple static rows, but it only works in the first one. This is my recycler view adapter code:

  • It may be important to note that the view which this recycler view is contained in is part of another view pager which is located inside a fragment.

     public class FeaturesListAdapter extends RecyclerView.Adapter<FeaturesListAdapter.ViewHolder> { public static final int NULL = -1; public static final int NUMBER_OF_FEATURES = 2; public static class ViewHolder extends RecyclerView.ViewHolder{ RelativeLayout root; ViewPager viewPager; public ViewHolder(RelativeLayout container, SampleActivity activity) { super(container); root = container; viewPager = (ViewPager) container.findViewById(R.id.view_pager); viewPager.setAdapter(new FeatureCellPagerAdapter(activity.getSupportFragmentManager(), activity)); viewPager.setCurrentItem(0); } } final SampleActivity mActivity; public FeaturesListAdapter(SampleActivity activity) { mActivity = activity; } @Override public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.view_holder_features_list, viewGroup, false); return new ViewHolder((RelativeLayout) view, mActivity); } @Override public void onBindViewHolder(ViewHolder viewHolder, int i) { } @Override public int getItemViewType(int position) { return NULL; } @Override public int getItemCount() { return NUMBER_OF_FEATURES; } 

    }

我已经遇到了这个问题,并通过为每个ViewPager设置ID来解决此问题:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM