title: Displaying a RecyclerView in a fragment
body: <p>I am trying to findViewById in order to add items to a recycler view. My code is below. Can anyway tell me why the following does not work.</p>
  
  <p>I do have a sample recycler view which should be appearing in the list, but it is not. </p>
  
  <p>Feel like I am missing something very obvious</p>
  
  <p>My fragment:</p>
  
  <pre><code>public class HolidayFragment extends Fragment {
  
      private HolidayViewModel holidayViewModel;
  
      @Override
      public View onCreateView(@NonNull LayoutInflater inflater,
                               ViewGroup container, Bundle savedInstanceState) {
          holidayViewModel =
                  ViewModelProviders.of(this).get(HolidayViewModel.class);
          View root = inflater.inflate(R.layout.fragment_holiday, container, false);
          FloatingActionButton fab = getActivity().findViewById (R.id.fab);
          fab.setImageResource (R.drawable.ic_add_black_24dp);
          fab.setOnClickListener (new View.OnClickListener() {
              @Override
              public void onClick (View view) {
                  Snackbar.make (view , "Holiday Fragment Action Button", Snackbar.LENGTH_LONG)
                          .setAction (" Action ", null ).show();
              }
          });
      RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.recyclerview);
      final HolidayListAdapter adapter = new HolidayListAdapter(getActivity());
      recyclerView.setAdapter(adapter);
      recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
          return root;
      }
  }
  </code></pre>
  
  <p>MyListAdapter:</p>
  
  <pre><code>public class HolidayListAdapter extends RecyclerView.Adapter&lt;HolidayListAdapter.HolidayViewHolder&gt; {
  
      private final LayoutInflater mInflater;
      private List&lt;Holiday&gt; mHolidays; // Cached copy of words
  
      HolidayListAdapter(Context context) { mInflater = LayoutInflater.from(context); }
  
      @Override
      public HolidayViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemView = mInflater.inflate(R.layout.recyclerview_item, parent, false);
          return new HolidayViewHolder(itemView);
      }
  
      @Override
      public void onBindViewHolder(HolidayViewHolder holder, int position) {
          if (mHolidays != null) {
              Holiday current = mHolidays.get(position);
              holder.holidayItemView.setText(current.getName());
          } else {
              // Covers the case of data not being ready yet.
              holder.holidayItemView.setText("No Holiday");
          }
      }
  
      void setHolidays(List&lt;Holiday&gt; holidays){
          mHolidays = holidays;
          notifyDataSetChanged();
      }
  
      // getItemCount() is called many times, and when it is first called,
      // mWords has not been updated (means initially, it's null, and we can't return null).
      @Override
      public int getItemCount() {
          if (mHolidays != null)
              return mHolidays.size();
          else return 0;
      }
  
      class HolidayViewHolder extends RecyclerView.ViewHolder {
          private final TextView holidayItemView;
  
          private HolidayViewHolder(View itemView) {
              super(itemView);
              holidayItemView = itemView.findViewById(R.id.textView);
          }
      }
  }
  </code></pre>
  
  <p>My Main Activity: </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      private AppBarConfiguration mAppBarConfiguration;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Toolbar toolbar = findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
  
          DrawerLayout drawer = findViewById(R.id.drawer_layout);
          NavigationView navigationView = findViewById(R.id.nav_view);
          // Passing each menu ID as a set of Ids because each
          // menu should be considered as top level destinations.
          mAppBarConfiguration = new AppBarConfiguration.Builder(
                  R.id.nav_home, R.id.nav_holiday, R.id.nav_gallery, R.id.nav_slideshow,
                  R.id.nav_tools, R.id.nav_share, R.id.nav_send)
                  .setDrawerLayout(drawer)
                  .build();
          NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
          NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
          NavigationUI.setupWithNavController(navigationView, navController);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
      @Override
      public boolean onSupportNavigateUp() {
          NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
          return NavigationUI.navigateUp(navController, mAppBarConfiguration)
                  || super.onSupportNavigateUp();
      }
  }
  </code></pre>