In my class, I have created a variable...
private ImageView imgLayoutImgEditPet;
In the onCreate
method, I reference the variable...
imgLayoutImgEditPet = new ImageView(this);
I then add this ImageView
to the layout...
layoutImgEditPet.addView(imgLayoutImgEditPet);
This should work, yet I get this error...
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.LinearLayout.addView(android.view.View)' on a null object reference
How can I instantiate a new ImageView
to my layout?