title: Card views inside a recycler view mess up after scrolling
body: <p>I'm building an Android quiz app. Questions are saved in an SQLite database and are randomly picked out.</p>
  
  <p>For each question answered, I store that answer in an ArrayList of Strings. At the end, I have a RecyclerView that shows card views containing a question and answers. I pass two lists to the constructor - the first one contains the questions (with answers) and the second one contains selected answers.</p>
  
  <p>If the user's answer is correct, that answer is colored green. If it's incorrect, that answer is colored red and the correct answer is colored green. </p>
  
  <p>When the result are shown, everything is correct. But after scrolling down so that the card can no longer be seen and then scrolling back up, the colors are no longer correct. </p>
  
  <p><strong>Screenshots:</strong>
  "Pravilen" means correct and "Napačen" means incorrect/wrong. In all 4 cases I picked the bottom answer (even if it was incorrect).</p>
  
  <p><a href="http://i.stack.imgur.com/etgNs.png" rel="nofollow">Before scrolling</a></p>
  
  <p><a href="http://i.stack.imgur.com/rEn21.png" rel="nofollow">After scrolling</a></p>
  
  <p>Does anyone know why this happens? I've been trying to fix this for the past 2 days but I just don't see where it's going wrong. Thanks in advance.</p>
  
  <p><strong>Recycler view adapter code</strong> (sorry, the formatting may not be right):</p>
  
  <pre><code>public class RVAdapter extends RecyclerView.Adapter&lt;RVAdapter.QuestionViewHolder&gt; {
  
  List&lt;Question&gt; questionList;
  ArrayList&lt;String&gt; selectedAnswers;
  
  public static class QuestionViewHolder extends RecyclerView.ViewHolder {
      CardView cardView;
      TextView question;
      TextView answer1;
      TextView answer2;
      TextView answer3;
      TextView answer4;
  
      QuestionViewHolder(View itemView) {
          super(itemView);
          cardView = (CardView)itemView.findViewById(R.id.cardView);
          question = (TextView)itemView.findViewById(R.id.resultQuestion);
          answer1 = (TextView)itemView.findViewById(R.id.resultAnswer1);
          answer2 = (TextView)itemView.findViewById(R.id.resultAnswer2);
          answer3 = (TextView)itemView.findViewById(R.id.resultAnswer3);
          answer4 = (TextView)itemView.findViewById(R.id.resultAnswer4);
      }
  }
  
  
  public RVAdapter(List&lt;Question&gt; questionList, ArrayList&lt;String&gt; selectedAnswers) {
      this.questionList = questionList;
      this.selectedAnswers = selectedAnswers;
  }
  
  
  @Override
  public QuestionViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
      View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_view, viewGroup, false);
      return new QuestionViewHolder(view);
  }
  
  
  @Override
  public void onBindViewHolder(QuestionViewHolder holder, int position) {
      holder.question.setText(questionList.get(position).getQuestion());
  
      String answer1 = questionList.get(position).getAnswer1();
      String answer2 = questionList.get(position).getAnswer2();
      String answer3 = questionList.get(position).getAnswer3();
      String answer4 = questionList.get(position).getAnswer4();
      String correctAnswer = questionList.get(position).getCorrectAnswer();
      String selectedAnswer = selectedAnswers.get(position);
  
      if (answer1 == null) {
          holder.answer1.setVisibility(View.GONE);
      } else {
          holder.answer1.setVisibility(View.VISIBLE);
          holder.answer1.setText(answer1);
          if (answer1.equals(correctAnswer)) {
              holder.answer1.setTextColor(Color.GREEN);
          } else if (answer1.equals(selectedAnswer)) {
              holder.answer1.setTextColor(Color.RED);
          }
      }
      if (answer2 == null) {
          holder.answer2.setVisibility(View.GONE);
      } else {
          holder.answer2.setVisibility(View.VISIBLE);
          holder.answer2.setText(answer2);
          if (answer2.equals(correctAnswer)) {
              holder.answer2.setTextColor(Color.GREEN);
          } else if (answer2.equals(selectedAnswer)) {
              holder.answer2.setTextColor(Color.RED);
          }
      }
      if (answer3 == null) {
          holder.answer3.setVisibility(View.GONE);
      } else {
          holder.answer3.setVisibility(View.VISIBLE);
          holder.answer3.setText(answer3);
          if (answer3.equals(correctAnswer)) {
              holder.answer3.setTextColor(Color.GREEN);
          } else if (answer3.equals(selectedAnswer)) {
              holder.answer3.setTextColor(Color.RED);
          }
      }
      if (answer4 == null) {
          holder.answer4.setVisibility(View.GONE);
      } else {
          holder.answer4.setVisibility(View.VISIBLE);
          holder.answer4.setText(answer4);
          if (answer4.equals(correctAnswer)) {
              holder.answer4.setTextColor(Color.GREEN);
          } else if (answer4.equals(selectedAnswer)) {
              holder.answer4.setTextColor(Color.RED);
          }
      }
  }
  </code></pre>