RecyclerView 显示错误 贴出代码求指正

先说一下我是按照这个方法http://blog.csdn.net/lmj623565791/article/details/38173061写的RecyclerView ,然后已经显示出来了出来了
然后我写了一个RecyclerView监钮切换FRAGMENT
适配器重新写了一个 然后FirstFragment中的代码是这样写的
public class FirstFragment extends Fragment {

private RecyclerView mRecyclerView;
private GalleryAdapter2 mAdapter;
private List<Integer> mDatas;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.firstfragmentlayout, container, false);
    initDatas2();
    mRecyclerView = (RecyclerView) view.findViewById(R.id.fragmengrecv1);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(linearLayoutManager);

    mAdapter = new GalleryAdapter2(getActivity(), mDatas);
    mRecyclerView.setAdapter(mAdapter);
    return view;
}

private void initDatas2() {
    mDatas = new ArrayList<Integer>(Arrays.asList(R.drawable.smalltop1,
            R.drawable.smalltop2, R.drawable.smalltop3, R.drawable.smalltop4, R.drawable.smalltop5,
            R.drawable.smalltop1, R.drawable.smalltop2, R.drawable.smalltop3, R.drawable.smalltop4));
}

}


写完之后MainActivity中的RecyclerView就不能切换FRAGMENT了 请问是什么原因??
但是不在这个FRAGMENT里面加RecyclerView就可以。。

1个回答

这是要实现recyclerview嵌套么?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问