Attempt to invoke virtual method on a null Object Reference Fragment Asynctask

Asked

Viewed 60 times

0

I’ve been at this for days and I still don’t understand why this mistake, I have a Asynctask who takes a Urls of a database

I want to take the url and define the imageView

gives an error on this line imageviewArray[n].setImageBitmap(loadedImage);

int n;

public void onActivityCreated(Bundle bundle) {
  super.onActivityCreated(bundle);


    imageViewArray[0] = (ImageView) getView().findViewById(R.id.quick_profile_0);
    imageViewArray[1] = (ImageView) getView().findViewById(R.id.quick_profile_1);
    imageViewArray[2] = (ImageView) getView().findViewById(R.id.quick_profile_2);
    imageViewArray[3] = (ImageView) getView().findViewById(R.id.quick_profile_3);
    imageViewArray[4] = (ImageView) getView().findViewById(R.id.quick_profile_4);
    imageViewArray[5] = (ImageView) getView().findViewById(R.id.quick_profile_5);
    imageViewArray[6] = (ImageView) getView().findViewById(R.id.quick_profile_6);
    imageViewArray[7] = (ImageView) getView().findViewById(R.id.quick_profile_7);
    imageViewArray[8] = (ImageView) getView().findViewById(R.id.quick_profile_8);
    imageViewArray[9] = (ImageView) getView().findViewById(R.id.quick_profile_9);
    imageViewArray[10] = (ImageView) getView().findViewById(R.id.quick_profile_10);

    imageView = (ImageView) getView().findViewById(R.id.test);

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getActivity()).build();
    ImageLoader.getInstance().init(config);
}

public void test(String g, int i) {

    n = i;
    ImageLoader imageLoader = ImageLoader.getInstance();

                     // g = src url
    imageLoader.loadImage(g, new SimpleImageLoadingListener() {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage){

          // Error - ImageView = null
          imageViewArray[n].setImageBitmap(loadedImage);

        }
    });
}


//onPostExecute do Asynctask

protected void onPostExecute(String a) {
    super.onPostExecute(a);

    test(a, 1);
    //a = www.exemple.com/photo/photo.png
}
  • 1

    Where imageViewArray is initialized?

  • I’m sorry, I forgot to copy this " Imageview imageViewArray[] = new Imageview[11];"

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.