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

  • Home
  • SEARCH
  • 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 8355055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:44:40+00:00 2026-06-09T09:44:40+00:00

In the project I am working on, I was originally inheriting from ListActivity in

  • 0

In the project I am working on, I was originally inheriting from ListActivity in order to make activities with Listviews in them. But, as I have a base class to make settings menus, and other things simpler, I wanted to see if I could switch it over to a normal activity, in order to only have one base class. But my problem is, with one of the activities, Using Listactivity.Listadapter with the adapter I built works fine, but when I try to use the same adapter for a ListView.Adapter, it gives me a nullreferenceexeption. Looking in the documentation, it looks like both are calling for the same object type (IListAdapter) and I cannot for the life of me figure out why.

    private ListView ticketView;
    List<TicketViewModel> tickets;
    List<String> ticketInfo;
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        ticketView = (ListView)FindViewById(Android.Resource.Id.List);
        //pulls data from a remote source
        //and puts it into a string array
        tickets = new List<Ticket>();
        tickets = DataDownload();
        ticketInfo = new List<string>();
        foreach (Ticket tick in tickets)
        {
            ticketInfo.Add(tick.Subject);
        }

        //adapter I am using
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
        Resource.Layout.itemList, ticketInfo);

        //this one works
        ListAdapter = adapter;

        //this one does not
        ticketView.Adapter = adapter;
    }

I’m sure I’m missing something obvious, but I can’t for the life of me figure it out.

Edit:

Here’s the logcat

07-30 08:59:53.498 I/ActivityManager(  162): Starting: Intent { cmp=KahunaAndroid.KahunaAndroid/kahunaandroid.TicketList } from pid 2101
07-30 08:59:59.534 D/ViewConsistency( 2101): AbsListView android.widget.ListView@40845958 enabled= true
07-30 08:59:59.594 D/dalvikvm( 2101): GC_EXTERNAL_ALLOC freed 9K, 47% free 3405K/6407K, external 575K/587K, paused 55ms
07-30 08:59:59.604 D/ViewConsistency( 2101): AbsListView android.widget.ListView@40845958 enabled= true
07-30 09:00:02.947 D/ViewConsistency( 2101): AbsListView android.widget.ListView@40867758 enabled= true
07-30 09:00:02.947 D/ViewConsistency( 2101): AbsListView android.widget.ListView@40867758 enabled= true
07-30 09:00:03.498 W/ActivityManager(  162): Launch timeout has expired, giving up wake lock!
07-30 09:00:03.538 W/ActivityManager(  162): Activity idle timeout for HistoryRecord{40a0aa88 KahunaAndroid.KahunaAndroid/kahunaandroid.TicketList}
07-30 09:00:13.958 I/MonoDroid( 2101): UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
07-30 09:00:13.958 I/MonoDroid( 2101): at KahunaAndroid.TicketList.OnCreate (Android.OS.Bundle) [0x000aa] in C:\Users\david\Documents\Visual Studio 2010\Projects\AndroidApplication2\AndroidApplication2\Tickets\TicketList.cs:44
07-30 09:00:13.958 I/MonoDroid( 2101): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) [0x00010] in /Users/builder/data/lanes/monodroid-mac-monodroid-4.2.4-branch/9f7cbd60/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.App.Activity.cs:1490
07-30 09:00:13.958 I/MonoDroid( 2101): at (wrapper dynamic-method) object.50e53c19-ce69-4f39-9dda-0aec4e7e7dcd (intptr,intptr,intptr) <IL 0x00012, 0x00033>

And the Exception “System.NullReferenceException: Object reference not set to an instance of an object”

  • 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-09T09:44:41+00:00Added an answer on June 9, 2026 at 9:44 am

    Using the other page I had working with a similar list style, I got this one working after playing with it a bit. I think what was causing the error ( I made quite a few changes other than this one, so it is possible something else fixed it) was I was forgetting:

    SetContentView(Resource.Layout.itemList);
    

    before initializing the listview. After changing that, it works as expected. Since I wasn’t using that view to create the ListView I was using (from android.resource) I originally didn’t think that it was necessary to call it before getting the listview item.

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

Sidebar

Related Questions

I am working with an ASP.NET MVC project which was originally started from the
I'm debugging a fairly large project I've been working on (but did not originally
I was originally working from my desktop on a project. I then decide to
I have been working through a very small-scale WPF project in order to familiarize
I'm working on a project where I have to take data from one source
I have a project working fine under MSVS 2010 SP1. I'm trying to convert
I have a web project working perfecly on my web server and on my
I have a working project that Im amending, it crashes after trying to use
Currently my project is working perfectly on IOS development target 3.2 But as soon
I'm changing my project from working with Linq-to-SQL to working with Entity Framework. 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.