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 8044785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:20:10+00:00 2026-06-05T05:20:10+00:00

I have experience getting ListAdapters working, and have looked online for tutorials on custom

  • 0

I have experience getting ListAdapters working, and have looked online for tutorials on custom adapters to interface with a GridView, but I can’t seem to get mine working. I’m receiving a NullPointerException on my line:

image.setBackgroundColor(Color.GREEN);

My Activity and Adapter are as follows:
FixtureActivity:

package net.blakely.paul.Hyperion;

import android.os.Bundle;
import android.widget.GridView;
import com.actionbarsherlock.app.SherlockActivity;

public class FixtureActivity extends SherlockActivity {


    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fixtures);
        FixtureItemAdapter fia = new FixtureItemAdapter(this, 6);
        GridView grids = (GridView) findViewById(R.id.grids);
        grids.setAdapter(fia);

        }

}

FixtureItemAdapter:

package net.blakely.paul.Hyperion;

import android.app.Activity;
import android.graphics.Color;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class FixtureItemAdapter extends BaseAdapter {

    private Activity context;
    public int size;
    private ImageView image;
    private TextView label;

    public FixtureItemAdapter(Activity context, int size) {
        super();
        this.context = context;
        this.size = size;
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return size;
    }

    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }



    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub


        Log.v("Hyperion","convertView is Null?="+Boolean.toString(convertView==null));
        if (convertView == null) {
            LayoutInflater inflater = context.getLayoutInflater();
            convertView = (LinearLayout) inflater.inflate(net.blakely.paul.Hyperion.R.layout.outputitem, null, true);

            image = (ImageView) convertView.findViewById(net.blakely.paul.Hyperion.R.id.imageView1);
            Log.v("Hyperion","image is Null?="+Boolean.toString(image==null));
            label = (TextView) convertView.findViewById(net.blakely.paul.Hyperion.R.id.textView2);


        } 

        // Decide which channel this is and set information accordingly

        image.setBackgroundColor(Color.GREEN);
        label.setText("LABEL");

        return convertView;
    }

}

Any help with this issue would be much appreciated. For what it’s worth. I’ve found that I get the NPE on the first run through the adapter, when convertView is null, and image winds up being null as well.

  • 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-05T05:20:12+00:00Added an answer on June 5, 2026 at 5:20 am

    I’m sorry, but I found out my problem. It turned out that I was calling the wrong xml file, outputitem instead of fixtureitem, since I had copied that line from a different ListAdapter in the program. Thanks for your answers.

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

Sidebar

Related Questions

Does anyone have any experience on getting Hibernate working with ZK? Thanks Edit: Sorry
I have experience about PDO but I was working with MySQL so far. I
Anyone have any experience yet getting Radiant CMS extensions to actually make it onto
I have experience with RelativeLayout but I've never run across a way to solve
Anyone have experience with this plugin? I have it installed but I have no
I have experience with C++ but I've never really used Qt before. I'm trying
I do a lot of work with GWT but don't have experience of Flex.
I have no experience working with Perl, and I'm trying to run the geo_to_mysql.pl
Does anyone have experience working with language workbench tools such as Xtext, Spoofax, and
I am a beginner at C++ but I have some experience using Java. I

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.