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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:05:18+00:00 2026-06-01T22:05:18+00:00

I’m developing and Android App on 4.0.3 and have several ListActivities using their own

  • 0

I’m developing and Android App on 4.0.3 and have several ListActivities using their own CursorAdapters. If I’m using only one customized CursorAdapter everything works fine but when I’m using more my application crashes.

Error stack:

    04-10 15:41:08.897: W/dalvikvm(2239): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
    04-10 15:41:08.956: E/AndroidRuntime(2239): FATAL EXCEPTION: main
    04-10 15:41:08.956: E/AndroidRuntime(2239): java.lang.NullPointerException
    04-10 15:41:08.956: E/AndroidRuntime(2239):     at com.tsystems.openconf.database.adapter.ConferenceListCursorAdapter.bindView(ConferenceListCursorAdapter.java:38)
    04-10 15:41:08.956: E/AndroidRuntime(2239):     at android.widget.CursorAdapter.getView(CursorAdapter.java:250)
    ...

It seems that Android can’t handle several ListActivities.

All of my inherited ListActivity classes include the following code, except of the CursorAdapter class:

public void onCreate(Bundle savedInstanceState) {
        Log.d(TAG, "onCreate called");
        super.onCreate(savedInstanceState);

        Log.d(TAG, "create DatabaseOpenHelper");
        DatabaseOpenHandler helper = new DatabaseOpenHandler(this);

        Log.d(TAG, "get writeable database access");
        database = helper.getWritableDatabase();

        Log.d(TAG, "create Cursor for database access");
        data = database.query(DatabaseConstants.TABLE_CONFERENCES, fields,
                null, null, null, null, null);

        Log.d(TAG, "set ConferenceListCursorAdapter");
        setListAdapter(new ConferenceListCursorAdapter(this, data));
    }

My customized inherited CursorAdapter looks like this and overwrites the bindView and newView method:

public class ConferenceListCursorAdapter extends CursorAdapter {

    // logging identifier
    private static final String TAG = ConferenceListCursorAdapter.class.getSimpleName();

    private Cursor cursor;

    private Context context;

    private final LayoutInflater inflater;

    public ConferenceListCursorAdapter(Context context, Cursor cursor) {
        super(context, cursor, true);
        this.inflater = LayoutInflater.from(context);
        this.context = context;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        Log.d(TAG, "bindView of ConferenceListAdapter called");

        TextView test = (TextView) view.findViewById(R.id.conference_list_id);

        test.setText(Long.toString(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCES_STARTTIMEINMILLIS))));

    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        return inflater.inflate(R.layout.conference_list_item, parent, false);
    }
}

EDIT

In line 38 is written:

 test.setText(Long.toString(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.CONFERENCES_STARTTIMEINMILLIS))));

It looks like Android can’t find the TextView and therefore throws the NPE when setting the text. The id of the test TextView is written in the R class and should be found by Android. So why does it throws the NPE?

code snippet of my layout xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/conference_list_id"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true" />

</RelativeLayout>
  • 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-01T22:05:21+00:00Added an answer on June 1, 2026 at 10:05 pm

    I fixed the problem by using ArrayAdapter instead of CursorAdapter. I had to change a lot but now everything works fine.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
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 have a jquery bug and I've been looking for hours now, I can't

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.