title: NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView
body: <p>I want to attach a fragment when the app launches and set an Image by downloading form an API. I had initialized the image but I keep getting a NullPointerException even if it seems everything fine to me. I would appreciate if anyone can show me out where I made the mistake.</p>
  
  <pre><code>public class AnasayfaFragment extends Fragment implements AnasayfaView {
      AnasayfaPresenter mAPresenter;
      private ImageView bannerImage;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
  
  
          // Inflate the layout for this fragment
          View view = inflater.inflate(R.layout.fragment_anasayfa, container, false);
          bannerImage = (ImageView) view.findViewById(R.id.bannerImage);
          mAPresenter = new AnasayfaPresenterImp(this,new AnasayfaInteractorImp());
          mAPresenter.passData();
          return view;
  
      }
  
  
      @Override
      public void showImage(Bitmap value) {
  
          bannerImage.setImageBitmap(value);
          Log.i("info","we are in view" + value);
      }
  </code></pre>
  
  <p>this is my layout</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:id="@+id/anasayfaFragment"
      tools:context="com.nejat.yemektarifi.AnaSayfa.AnasayfaFragment"&gt;
  
  
          &lt;ImageView
              android:id="@+id/bannerImage"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              app:srcCompat="@mipmap/ic_launcher"
              android:layout_gravity="center_horizontal"
              /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Log file</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference
                                                                             at com.nejat.yemektarifi.AnaSayfa.AnasayfaFragment.showImage(AnasayfaFragment.java:40)
  </code></pre>