Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9149837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:31:52+00:00 2026-06-17T11:31:52+00:00

I’m getting a nullpointer exception when I try to set images in a gridview

  • 0

I’m getting a nullpointer exception when I try to set images in a gridview using Universal Image Loader. The crash happens just as the first image is downloaded and exactly one image is downloaded before the application crashes. (Checked with httpscoop)

Edit:
This is wrong. The crash happens before the first image is downloaded, so it probably tries to measure an image that is non existent.

This is my griditem

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
    android:id="@+id/gridImageView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:src="@drawable/ic_launcher"
    android:contentDescription="@string/gallery_grid_image_desc"/>

The gridview layout is simply a gridview

<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/galleryPicturesGrid"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:verticalSpacing="@dimen/gallery_grid_spacing"
    android:horizontalSpacing="@dimen/gallery_grid_spacing"
    android:numColumns="3" />

My getView

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder holder = null;
        Log.d(TAG, "getView " + position);

        if (view == null) {
            view = ((Activity) context).getLayoutInflater().inflate(
                    R.layout.gallery_grid_item, null);
            holder = new ViewHolder();
            holder.thumb = (ImageView) view.findViewById(R.id.gridImageView);

            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        Picture picture = mPictures.valueAt(position);

        mImageLoader.displayImage(picture.getThumbUrl(), holder.thumb, mImageOptions);

        return null;
    }

ImageLoader configuration

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            getApplicationContext()).memoryCacheSize(2 * 1024 * 1024)
            .discCache(new UnlimitedDiscCache(cacheDir))
            .denyCacheImageMultipleSizesInMemory()
            .offOutOfMemoryHandling()
            .threadPoolSize(4)
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .memoryCache(new UsingFreqLimitedMemoryCache(2 * 1024 * 1024))
            .tasksProcessingOrder(QueueProcessingType.LIFO)
            .imageDownloader(new UrlConnectionImageDownloader(this))
            .build();

and Options

    galleryThumbImageOptions = new DisplayImageOptions.Builder()
    .showStubImage(R.drawable.p1_cover)
    .cacheOnDisc()
    .bitmapConfig(Bitmap.Config.RGB_565)
    .build();

and the exception

01-18 10:56:15.434: E/AndroidRuntime(4089): FATAL EXCEPTION: main   
01-18 10:56:15.434: E/AndroidRuntime(4089): java.lang.NullPointerException
01-18 10:56:15.434: E/AndroidRuntime(4089):     at     android.widget.GridView.onMeasure(GridView.java:937)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.View.measure(View.java:8313)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.os.Looper.loop(Looper.java:123)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at android.app.ActivityThread.main(ActivityThread.java:3683)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at java.lang.reflect.Method.invokeNative(Native Method)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at java.lang.reflect.Method.invoke(Method.java:507)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-18 10:56:15.434: E/AndroidRuntime(4089):     at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:31:53+00:00Added an answer on June 17, 2026 at 11:31 am

    It is an error to return null from getView(), you should be returning the row item that you just inflated or converted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JSon response to parse title,date content and thumbnail images and place
I am using jsonparser to parse data and images obtained from json response. When
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.