java Android RecyclerView内部视图寻呼机
我想把RecyclerView放在一个ViewPager元素中
但当我尝试在MainActivity中初始化RecyclerView时,我得到了一个NullPointerException
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mRecyclerView始终为空
有人能解释一下我怎样才能把RecyclerView放进ViewPager里吗
编辑:我没有使用片段
更新:这里是XML文件
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:orientation="vertical" 安卓:layout_width="match_parent"
安卓:background="@color/colorPrimaryGrey"
安卓:layout_height="match_parent">
<安卓.support.v7.widget.RecyclerView
安卓:paddingTop="58dp"
安卓:id="@+id/recycler_view"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent">
</安卓.support.v7.widget.RecyclerView>
</RelativeLayout>
共 (0) 个答案