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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:08:36+00:00 2026-05-23T21:08:36+00:00

Here is a short List activity that calls a custom adapter to show class

  • 0

Here is a short List activity that calls a custom adapter to show class room attendance.
I set up the data using the classroom rowid that was clicked to get here and then query my
DB to get all students in the class. I use a custom adapter because I have a list of checkboxes
along with student names. No matter if I use my adapter or simply substitute in simplecursoradapter (and lose my checkbox functionality) upon exit I get a null pointer exception. This happens whether
I click the “done” button or click the back arrow. I can’t seem to see anything. Can you?

public class ShowStudentAttendance extends ListActivity {
private gradeBookDbAdapter mDbHelper;
private Long mRowId;
private TextView mNameText;
private String classname;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Cursor stud;

    mDbHelper = new gradeBookDbAdapter(this);
    mDbHelper.open();
    mRowId = (savedInstanceState == null) ? null
            : (Long) savedInstanceState
                    .getSerializable(gradeBookDbAdapter.KEY_ROWID);
    if (mRowId == null) {
        Bundle extras = getIntent().getExtras();
        mRowId = extras != null ? extras
                .getLong(gradeBookDbAdapter.KEY_ROWID) : null;
    }
    if (mRowId != null) {
        stud = mDbHelper.fetchClass(mRowId);
        startManagingCursor(stud);

        classname = stud.getString(
                stud.getColumnIndexOrThrow(gradeBookDbAdapter.KEY_CLASSNAME));
        String title = "Attendance for " + classname;
        setTitle(title);
    }
    stud = mDbHelper.fetchAllStudentsClass(mRowId);
    startManagingCursor(stud);
    setContentView(R.layout.attendance_list);
    Button doneButton = (Button) findViewById(R.id.Done);
    doneButton.setOnClickListener(mAttendanceActivity);


    // Create an array to specify the fields we want to display in the list (only name)
    String[] from = new String[]{gradeBookDbAdapter.KEY_NAME,
            gradeBookDbAdapter.KEY_ROWID};

    // and an array of the fields we want to bind those fields to (in this case just text1)
    int[] to = new int[]{R.id.stuname};

    // Now create a simple cursor adapter and set it to display
    MyDataAdapter studs = 
       new MyDataAdapter(this, R.layout.show_attendance, stud, from, to);
    setListAdapter(studs);
}
private OnClickListener mAttendanceActivity = new OnClickListener() {
    public void onClick(View v) {
        setResult(RESULT_OK);
        finish();
    }

};

}
  • 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-23T21:08:37+00:00Added an answer on May 23, 2026 at 9:08 pm

    Oops. Nevermind. I was looking in the wrong place. Nothing wrong with this code. I was just calling the activity with startActivityForResult and didn’t need to and never had an onActivityResult(). I changed it to a simple startActivity and all is well again. Thanks for looking, though. –

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

Sidebar

Related Questions

I have a SVNSERVE server set up to host multiple repositories. Short question here
First question here: it is a very short yet fundamental thing in Java that
I've been charged with building a documentation system/platform. Here's a short list of the
I have two classes in short here they are: public final class ServerMain {
HEre is my RegisterActivity: public class RegisterActivity extends Activity { /** Called when the
Here is my short implementation of Russian Peasant Multiplication . How can it be
Here's a short test program: sub foo($;@) { my $sql = shift; my @params
Here's the following algorithm: int encryption(int a, int b) { short int c, c2;
So here's a snippet of my code: struct dv_nexthop_cost_pair { unsigned short nexthop; unsigned
Short question - how do you define your view models? Here are some of

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.