ImageView NullPointer error
I have this error: java.lang.NullPointerException : Attempting to call the virtual void android.widget.ImageView.setImageResource (int) 'virtual method for a null object reference
I followed the step to put it ImageView
into action. How does the error occur and how to fix it? It is noted that in hasis_layout I am using RecylerView
. Thanks to
-
My ImageView
<ImageView android:layout_width="match_parent" android:layout_height="0dp" android:id="@+id/hadisView" android:layout_gravity="center_horizontal" android:layout_weight="0.36" android:contentDescription="Hadis" android:src="@drawable/hadith01arabic"/>
-
My activity
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hadis_layout); toolbar = (Toolbar) findViewById(R.id.tool_bar); setSupportActionBar(toolbar); ImageView imageView = (ImageView) findViewById(R.id.hadisView); imageView.setImageResource(R.drawable.hadith01arabic); }
+3
chemat92
source
to share
No one has answered this question yet
Check out similar questions:
1858
935
746
561
528
517
255
241
7
0