title: Android - Programming Style - RecyclerView - Use SetText in ViewHolder or in onBindViewHolder?
body: <p>When setting <code>OnClickListeners</code> to items in the <code>RecyclerView</code> it's recommended to do that in the inner class like this: </p>
  
  <pre><code>public ViewHolder(View itemView) {
      super(itemVIew);
      nameTextView = (TextView) itemView.findViewById(R.id.item_name);
      itemView.setOnClickListener(this);
  }
  </code></pre>
  
  <p>When I see code for setting text it's usually in the <code>onBindViewHolder</code> method:</p>
  
  <pre><code>@Override
  public void onBindViewHolder(SetPlayerNameViewHolder holder, int position) {
      holder.nameTextView.setText(String.valueOf("Random Text"));
  }
  </code></pre>
  
  <p>If the text never changes, shouldn't it be in the inner class? </p>
  
  <pre><code>public ViewHolder(View itemView) {
      super(itemVIew);
      nameTextView = (TextView) itemView.findViewById(R.id.item_name);
      nameTextView.setText(String.valueOf("Random Text"));
      itemView.setOnClickListener(this);
  }
  </code></pre>
  
  <p><strong>Edit: And what if you retrieve a value that is different for all <code>TextViews</code>, but should not be updated when the <code>RecyclerView</code> reloads it</strong></p>
  
  <pre><code>public ViewHolder(View itemView) {
      super(itemVIew);
      nameTextView = (TextView) itemView.findViewById(R.id.item_name);
  
      // Not the actual methods, but to make it more readable
      int i = itemView.getPosition()
      String randomText = getTextFromDatabaseWhereRowIs(i)
  
      nameTextView.setText(String.valueOf(randomText));
      itemView.setOnClickListener(this);
  }
  </code></pre>