title: How to add user data to my Recyclerview through onClick?
body: <p>I'm trying to build a simple To Do List app using a RecyclerView with a custom Adapter.  I've build a model data class to get and set my todos.  My problem is that each time I click the button to add my item, nothing happens.  I did call <code>notifyDataSetChanged()</code> method but it still doesn't work.</p>
  
  <p>This is a practice app that I'm building to learn RecyclerViews and custom adapters so I'd appreciate it if someone could explain why it doesn't work and perhaps explain to me how I can fix it.</p>
  
  <p>This is my code where I'm retrieving the user input from the EditText field and placing it in my data:</p>
  
  <pre><code>    public class MainActivity extends AppCompatActivity {
  
          private ToDoData toDoData;
  
          private List&lt;ToDoData&gt; toDoList = new ArrayList&lt;&gt;();
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
  
              final ToDoAdapter toDoAdapter = new ToDoAdapter(toDoList, this);
              toDoData = new ToDoData(this);
  
              final EditText toDoInput = (EditText)findViewById(R.id.add_todo);
              Button toDoAdd = (Button)findViewById(R.id.add_item);
  
              RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
              RecyclerView toDoDisplay = (RecyclerView) findViewById(R.id.toDoDisplayRecyclerView);
              toDoDisplay.setAdapter(toDoAdapter);
              toDoDisplay.setHasFixedSize(true);
              toDoDisplay.setLayoutManager(layoutManager);
  
  
              toDoAdd.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      toDoData.setToDo(toDoInput.getText().toString());
                      toDoAdapter.notifyDataSetChanged();
                  }
              });
  
          }
      }
  </code></pre>
  
  <p>This is my model class with getters and setters.  The list-item has only 1 field so its rather small:</p>
  
  <pre><code>public class ToDoData {
      private String toDoString;
  
      public ToDoData(String todoString){
          this.toDoString = todoString;
      }
  
      public ToDoData(Context context){}
  
      public String getToDo() {
          return toDoString;
      }
  
      public void setToDo(String toDoString) {
          this.toDoString = toDoString;
      }
  }
  </code></pre>
  
  <p>And this is my custom adapter.  I followed through a tutorial while building this but I do however think that my problem stems from the adapter:</p>
  
  <pre><code>public class ToDoAdapter extends RecyclerView.Adapter&lt;ToDoAdapter.ViewHolder&gt; {
  
      private List&lt;ToDoData&gt; toDoList;
      private Context context;
  
      public ToDoAdapter(List&lt;ToDoData&gt; todoList, Context context) {
          this.toDoList = todoList;
          this.context = context;
      }
  
      public class ViewHolder extends RecyclerView.ViewHolder {
          TextView todoView;
  
          public ViewHolder(View itemView) {
              super(itemView);
              todoView = (TextView) itemView.findViewById(R.id.to_do_display);
          }
      }
  
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.to_do_list_item, parent, false);
          return new ViewHolder(view);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          ToDoData todo = toDoList.get(position);
  
          holder.todoView.setText(todo.getToDo());
      }
  
      @Override
      public int getItemCount() {
          return (toDoList == null) ? 0 : toDoList.size();
      }
  }
  </code></pre>