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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:00:26+00:00 2026-05-26T21:00:26+00:00

Hi I started programming a ToDo-List on android (in eclipse) which synchronises with Google

  • 0

Hi I started programming a ToDo-List on android (in eclipse) which synchronises with Google Tasks and add tasks from your Google Account.
I implemented a really simple database (according to this tutorial: SQLITE Tutorial).
The project contains one activity, which only implements a listView and a button which allows it to add tasks.(parent activity)
By clicking the button a new acitvity is started via “startActivityForResult” and you can enter a name and a category.(child activity)
Then this two strings are passed to the parent activity and added to the database, which is initialized in the parent activity
Now, the listview should be created and a simpleCursorAdapter should be set; thats the point where the app crashes, on the emulator and on my android handy.
Heres a code snippet of the start activity:

 @Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    initDB();
    initUI();
}

public void initUI()
{
    Log.w(TAG, "initUI()");
    populateToDoList();

    listView = (ListView) findViewById(R.id.tasklist);
    addButton = (Button) findViewById(R.id.addTask);

    addButton.setOnClickListener(new OnClickListener()
    {

        @Override
        public void onClick(View arg0) 
        {
            // TODO Auto-generated method stub
            Intent i = new Intent(RememberMe.this, AddTask.class);
            startActivityForResult(i, REQUEST_CODE);
    }   });
}

public void initDB()
{
    toDoDBAdapter = new ToDoDBAdapter(RememberMe.this);
    toDoDBAdapter.open();
}

private void populateToDoList() 
{

    Log.w(TAG, "populateToDoList()");

    dbCursor = toDoDBAdapter.getAllToDoItemsCursor();
    Log.w(TAG, "getAllToDoItemsCursor()");

    startManagingCursor(dbCursor);
    Log.w(TAG, "startManagingCursor()");

    String [] columns = { ToDoDBAdapter.KEY_NAME};
    int [] to = { android.R.id.text1 };
    Log.w(TAG, "Sring from int to");

    simpleCursor = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, dbCursor, columns, to);
    Log.w(TAG, "new SimpleCursorAdapter()");

    listView.setAdapter(simpleCursor);
    Log.w(TAG, "setAdapter()");

    simpleCursor.notifyDataSetChanged();    

}

private void updateList() 
{

    dbCursor.requery();
    simpleCursor.notifyDataSetChanged();

}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if(resultCode == REQUEST_CODE)
    {
        String taskName = data.getStringExtra("taskName");
        String taskCategory = data.getStringExtra("taskCategory");

        toDoDBAdapter.createTask(taskName, taskCategory);

        updateList();

        Toast.makeText(this, "Aufgabe hinzugefügt", Toast.LENGTH_LONG).show();
    }
}

@Override
public void onDestroy() 
{
    super.onDestroy();
    toDoDBAdapter.close();
}
}

It stops at

listView.setAdapter(simpleCursor);
Log.w(TAG, "setAdapter()");

I’ve no idea why or what’s the problem; I read that there are problems with the emulator on a 64-bit system but the code doens’t work either on my handy and implementing listviews and setting a simpleCursor should not be so tricky O.o
Heres the logcat:
LogCat

  • 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-05-26T21:00:27+00:00Added an answer on May 26, 2026 at 9:00 pm

    Have you checked to make sure that listView is in fact not null? Debug your code, step all the way up to listView.setAdapter(simpleCursor); and hover over listView to see if it is null.

    EDIT: You did find that it was in fact null, here is the most common reason(s) that I have found:

    listView = (ListView) findViewById(R.id.tasklist);
    

    R.id.tasklist is CASE sensitive, make sure in your XML it is not @+id/taskList or something similar or this will return null

    Also make sure it is spelled exactly right, as it could just be a case of misspelling.

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

Sidebar

Related Questions

I've started programming an Android application which implements a ListView and a simple Database
Need some advice from you experts out there. I've just started with Android programming
I just started programming in C# and was reading about dividing your application /
I am trying to help some people getting started programming on rails identify which
How do you work? More specifically, how do you keep your programming tasks organized.
I've started Android programming recently so bear with me :) I develop an app
I recently started out with iOS programming (with the Stanford CS193P lectures from iTunes
i have just started android programming, wrote a quick code, and havn't managed to
I just started programming for android. I'm using a tab based layout in my
I'm new to Android app programming and started to read a book, but it

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.