RecyclerView无法访问

时间:2018-01-15 22:59:17

标签: android

我正在学习RecyclerView并且我的回收商遇到了问题:

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/bootik_recycler"
    />

上课:

public class BotikFragment extends Fragment {

  private RecyclerView recyclerView;
  private View view;

  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

   View view=inflater.inflate(R.layout.recycler_botik,container);

     return view;
     recyclerView=(RecyclerView)view.findViewById(R.id.bootik_recycler);

我收到Unreachable Statement错误。

1 个答案:

答案 0 :(得分:1)

只是将最后两个语句按不同顺序排列:

recyclerView=(RecyclerView)view.findViewById(R.id.bootik_recycler);
return view;