-3

I'm building a reyclerView that loads images into the titleChild. I uploaded test_image into res/drawable but I keep seeing null object reference at

titleChildViewHolder.option1.setImageResource(R.drawable.test_image);
titleChildViewHolder.option2.setImageResource(R.drawable.test_image);

enter image description here

Pembroke
  • 113
  • 2
  • 9

1 Answers1

0

In your xml file where you define the ImageView I suggest you to set the src of the imageview to test_image.

<ImageView
        android:id="@+id/option1"
        android:layout_centerHorizontal="true"
        android:src="@drawable/test_image" />

Also check that the file is present in your res/drawable which many a times results in NPE.

Akshay
  • 1,161
  • 1
  • 12
  • 33