title: RecyclerView doesn't inflate, rather updates the same view?
body: <p>I have an activity to implement a to-do list, containing a recyclerview with each item being a checkbox and textview, and each task is added from an edittext.
  It stores data using Realm.io. The behaviour that I keep getting is that the single element in the recyclerview merely get updated, and not inflated! Please help.</p>
  
  <p>TasksActivity - </p>
  
  <pre><code>public class TasksActivity extends AppCompatActivity implements View.OnClickListener{
  
      TextView courseTitle;
      RecyclerView TaskList;
      EditText addTask;
      Button addButton;
  
      String transName; //Transferred Course name from MainActivity
  
  
      TaskAdapter TA;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_tasks);
  
          courseTitle = findViewById(R.id.CourseName);
          TaskList = findViewById(R.id.TaskListRV);
          TaskList.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));
  
  
          addTask = findViewById(R.id.InputTask);
          addButton = findViewById(R.id.AddTaskButton);
  
          //Course name is the obtained from the previous acivity.
  
          transName =getIntent().getExtras().getString("CourseName");
          courseTitle.setText(transName);
  
          TA = new TaskAdapter(transName);
          TaskList.setAdapter(TA);
  
          addButton.setOnClickListener(this);
  
      }
  
      @Override
      public void onClick(View view) {
  
          String task = addTask.getText().toString();
  
          // Checking if the text is empty.
  
          boolean flag = false;
          for(int i = 0;i&lt;task.length();i++)
          {
              if(task.charAt(i)!=' ')
                  flag = true;
          }
  
          if(!flag || task.equals(""))
          {
              Toast emptyWarning = Toast.makeText(getApplicationContext(),"Task cannot be Empty!",Toast.LENGTH_SHORT);
              emptyWarning.show();
          }
          else
          {
              addTask.setText("");
              TA.addNewTask(task);
  
          }
      }
  
  }
  </code></pre>
  
  <p>TasksAdapter - </p>
  
  <pre><code>public class TaskAdapter extends RecyclerView.Adapter&lt;TaskViewHolder&gt; implements RealmChangeListener&lt;RealmResults&lt;TaskModel&gt;&gt;
  {
  
      private ArrayList&lt;TaskModel&gt; TaskList;
      private String course;
      private final Realm realm;
  
  
  
          public TaskAdapter(String course)
          {
              this.course = course;
  
              this.TaskList = new ArrayList&lt;&gt;();
              realm = Realm.getDefaultInstance();
              loadTaskData();
          }
  
          void loadTaskData()
          {
              RealmResults&lt;TaskModel&gt; taskModelRealmResults = realm.where(TaskModel.class).equalTo("courseName",course).findAll();
              taskModelRealmResults.addChangeListener(this);
  
              for(TaskModel iTM : taskModelRealmResults)
              {
                  TaskList.add(realm.copyFromRealm(iTM));
              }
              notifyDataSetChanged();
  
          }
  
          @Override
          public TaskViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
              LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
              View view= layoutInflater.inflate(R.layout.item_task,parent,false);
  
              TaskViewHolder Tvh = new TaskViewHolder(view);
              return Tvh;
          }
  
          @Override
          public void onBindViewHolder(TaskViewHolder holder, int position) {
              holder.populateTask(TaskList.get(position));
  
          }
  
          @Override
          public int getItemCount() {
              return TaskList.size();
          }
  
          public void addNewTask(String task)
          {
              TaskModel newTaskObj = new TaskModel(task,course,false);
  
              TaskList.add(newTaskObj);
              notifyDataSetChanged();
  
              realm.beginTransaction();
              realm.insertOrUpdate(newTaskObj);
              realm.commitTransaction();
  
          }
  
  
          @Override
          public void onChange(RealmResults&lt;TaskModel&gt; taskModels) {
  
              taskModels = realm.where(TaskModel.class).equalTo("courseName",course).findAll();
              this.TaskList = new ArrayList&lt;&gt;();
  
              for(TaskModel iTM : taskModels)
              {
                  this.TaskList.add(realm.copyFromRealm(iTM));
              }
              notifyDataSetChanged();
          }
  
      }
  </code></pre>
  
  <p>TaskViewHolder and TaskModel - (in case you might need them) </p>
  
  <pre><code>public class TaskModel extends RealmObject {
  
      String task;
  
      @PrimaryKey
      String courseName;
  
      boolean isDone;
  
      public TaskModel() {
          task = "";
          courseName = "";
          isDone = false;
      }
  
      public TaskModel(String task, String courseName, boolean isDone) {
          this.task = task;
          this.courseName = courseName;
          this.isDone = isDone;
      }
  
  
      public String getTask() {
          return task;
      }
  
      public void setTask(String task) {
          this.task = task;
      }
  
      public boolean isDone() {
          return isDone;
      }
  
      public void setDone(boolean done) {
          isDone = done;
      }
  }
  
  public class TaskViewHolder extends RecyclerView.ViewHolder  {
  
      CheckBox isdone;
      TextView Taskname;
  
  
      public TaskViewHolder(View itemView) {
          super(itemView);
  
          isdone = itemView.findViewById(R.id.TaskCheckBox);
          Taskname = itemView.findViewById(R.id.TaskName);
  
      }
  
      void populateTask(final TaskModel T)
      {
          Taskname.setText(T.getTask());
          isdone.setChecked(T.isDone());
  
          isdone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                  T.setDone(isdone.isChecked());
              }
          });
      }
  
  }
  </code></pre>