在onCreateView中再添加setLayoutManager,setAdapter即可
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = LayoutInflater.from(getContext()).inflate(R.layout.tab_fragment1, null);
unbinder = ButterKnife.bind(this, view);
tabfragment1Recycler.setLayoutManager(new LinearLayoutManager(getContext()));
//创建适配器
tabFragmentReAdapter = new TabFragmentReAdapter(list, getContext());
tabfragment1Recycler.setAdapter(tabFragmentReAdapter);
return view;
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
tabfragment1Recycler.setLayoutManager(new LinearLayoutManager(getContext()));
//创建适配器
tabFragmentReAdapter = new TabFragmentReAdapter(list, getContext());
tabfragment1Recycler.setAdapter(tabFragmentReAdapter);