java - List<MyStructure> error: App crashes, No idea why -


i've built class named "item", here it: (thats whole code)

public class item { private int id; private string title; private string desc; private double lat; private double lon; private string pub; private int p; private int n;  public item(int id, string title, string desc, double lat, double lon, string pub, int p, int n) {     super();     this.id = id;     this.title = title;     this.desc = desc;     this.lat = lat;     this.lon = lon;     this.pub = pub;     this.p = p;     this.n = n; } 

now have make list<item> , add() "item"s it, reason application crushes.

thats activity:

public class mainactivity extends activity {      list<item> markers;     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          item = new item(1, "lol", "sdfs", 32.45345, 34.54353, "nir", 0, 0);         markers.add(a);       } 

logcat:

08-10 16:32:46.710: d/androidruntime(2934): shutting down vm 08-10 16:32:46.710: w/dalvikvm(2934): threadid=1: thread exiting uncaught exception (group=0x41a0a930) 08-10 16:32:46.777: e/androidruntime(2934): fatal exception: main 08-10 16:32:46.777: e/androidruntime(2934): java.lang.runtimeexception: unable start activity componentinfo{com.example.testitems/com.example.testitems.mainactivity}: java.lang.nullpointerexception 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2308) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2358) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread.access$600(activitythread.java:153) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread$h.handlemessage(activitythread.java:1247) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.os.handler.dispatchmessage(handler.java:99) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.os.looper.loop(looper.java:137) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread.main(activitythread.java:5227) 08-10 16:32:46.777: e/androidruntime(2934):     @ java.lang.reflect.method.invokenative(native method) 08-10 16:32:46.777: e/androidruntime(2934):     @ java.lang.reflect.method.invoke(method.java:511) 08-10 16:32:46.777: e/androidruntime(2934):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:795) 08-10 16:32:46.777: e/androidruntime(2934):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:562) 08-10 16:32:46.777: e/androidruntime(2934):     @ dalvik.system.nativestart.main(native method) 08-10 16:32:46.777: e/androidruntime(2934): caused by: java.lang.nullpointerexception 08-10 16:32:46.777: e/androidruntime(2934):     @ com.example.testitems.mainactivity.oncreate(mainactivity.java:18) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activity.performcreate(activity.java:5104) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1080) 08-10 16:32:46.777: e/androidruntime(2934):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2262) 08-10 16:32:46.777: e/androidruntime(2934):     ... 11 more 

appreciate guys!

initialize markers list

list<item> markers=new arraylist<item>(); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -