I want to create the following:
a main activity Class which creates/uses a Class which has several
fields, each of which has two pieces of data, a String "value" and a
Boolean "visible" (describing whether that piece of data will be
visible to other users). I have done this by creating a subClass which
basically is a "record" containing two fields.

But the following code fails. It fails whenever I try to assign a
value to the "value" field or the "visibility" field. (It fails with
either direct assignment or with creating a setter method -not
shown.).  The error code indicates a null pointer exception is thrown
when I try to make the assignment, but I do not know why this should
be the case, or how to fix it.... (BTW if I don't use the extra
subClass containing two pieces of data, and just use a String type in
the primary Class, it works fine, but that's not what I was hoping to
do...)

(Oh, I am still using 0.9, but I don't think this is related to
that...)

Any help would be greatly appreciated, Thanks, Jim.


CODE:
import com.northwestradiology.com.Person1.StrRecord;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;

public class ResourceQuestion extends ListActivity  {

        public class Person2 {

                public class StrRecord {
                        String value;
                        Boolean visible;
                }

                public StrRecord Id;

                public Person2(Context ctx) {
                        super();
                        Log.v("person construct", "before Id.value= hola...");
                        Id.value = "hola";
                        Log.v("person construct", "after Id.value= hola...");

                }
        }

        /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
                Log.v("onCreate", "entering on create");
                Person2 me = new Person2(this);
                Log.v("onCreate", "after person2 is constructed");
//              Log.v("onCreate", "after person1 is constructed");
//              me.Id = "hola";
//              Log.v("onCreate", "after me.Id.value set to hola");

    }
}


LogCat:
09-26 23:10:33.678: VERBOSE/onCreate(2937): entering on create
09-26 23:10:33.678: VERBOSE/person construct(2937): before Id.value=
hola...
09-26 23:10:33.688: DEBUG/AndroidRuntime(2937): Shutting down VM
09-26 23:10:33.688: WARN/dalvikvm(2937): threadid=3: thread exiting
with uncaught exception (group=0x40010e28)
09-26 23:10:33.688: ERROR/AndroidRuntime(2937): Uncaught handler:
thread main exiting due to uncaught exception
09-26 23:10:33.708: ERROR/AndroidRuntime(2937):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.northwestradiology.com/
com.northwestradiology.com.ResourceQuestion}:
java.lang.NullPointerException
09-26 23:10:33.708: ERROR/AndroidRuntime(2937):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2131)

etc...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to