android - getting java.lang.ArrayIndexOutOfBoundsException -
ares = null; adob = null; ares = tres.split("-"); if (!ares[0].tostring().equals("0")) { (int = 0; <= ares.length - 1; i++) { adob = ares[i].tostring().split(","); // txtv = new textview(albums.this); valuetv = new textview(albums.this); valuetv.settext(adob[0].tostring() + "[" + adob[1].tostring() + "]"); // here getting exception ! // valuetv.setid(i); valuetv.setgravity(gravity.center); valuetv.setlayoutparams(new layoutparams( layoutparams.fill_parent, layoutparams.wrap_content)); valuetv.settextsize(20); valuetv.settextcolor(color.blue); valuetv.setclickable(true);
error logcat is
08-26 14:35:00.945: w/dalvikvm(21180): threadid=1: thread exiting uncaught exception (group=0x409e61f8) 08-26 14:35:00.975: d/dalvikvm(21180): gc_concurrent freed 218k, 4% free 6798k/7047k, paused 2ms+3ms 08-26 14:35:00.975: e/androidruntime(21180): fatal exception: main 08-26 14:35:00.975: e/androidruntime(21180): java.lang.runtimeexception: unable start activity componentinfo{com.app.pixitch/com.app.pixitch.albums}: java.lang.arrayindexoutofboundsexception: length=1; index=1 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread.performlaunchactivity(activitythread.java:1956) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1981) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread.access$600(activitythread.java:123) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread$h.handlemessage(activitythread.java:1147) 08-26 14:35:00.975: e/androidruntime(21180): @ android.os.handler.dispatchmessage(handler.java:99) 08-26 14:35:00.975: e/androidruntime(21180): @ android.os.looper.loop(looper.java:137) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread.main(activitythread.java:4424) 08-26 14:35:00.975: e/androidruntime(21180): @ java.lang.reflect.method.invokenative(native method) 08-26 14:35:00.975: e/androidruntime(21180): @ java.lang.reflect.method.invoke(method.java:511) 08-26 14:35:00.975: e/androidruntime(21180): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 08-26 14:35:00.975: e/androidruntime(21180): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 08-26 14:35:00.975: e/androidruntime(21180): @ dalvik.system.nativestart.main(native method) 08-26 14:35:00.975: e/androidruntime(21180): caused by: java.lang.arrayindexoutofboundsexception: length=1; index=1 08-26 14:35:00.975: e/androidruntime(21180): @ com.app.pixitch.albums.oncreate(albums.java:79) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activity.performcreate(activity.java:4492) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1049) 08-26 14:35:00.975: e/androidruntime(21180): @ android.app.activitythread.performlaunchactivity(activitythread.java:1920) 08-26 14:35:00.975: e/androidruntime(21180): ... 11 more
when debug program step step working nice. when run program without debugging giving error like
unable start activity componentinfo{com.app.pixitch/com.app.pixitch.albums}: java.lang.arrayindexoutofboundsexception: length=1; index=1
ps.
line 79: valuetv.settext(adob[0].tostring() + "[" + adob[1].tostring() + "]");
put code in postexecute() of prevalb() asynctask rather in oncreate() method.
ares = tres.split("-"); if (!ares[0].tostring().equals("0")) { (int = 0; <= ares.length - 1; i++) { adob = ares[i].tostring().split(","); // txtv = new textview(albums.this); valuetv = new textview(albums.this); valuetv.settext(adob[0].tostring() + "[" + adob[1].tostring() + "]"); // valuetv.setid(i); valuetv.setgravity(gravity.center); valuetv.setlayoutparams(new layoutparams( layoutparams.fill_parent, layoutparams.wrap_content)); valuetv.settextsize(20); valuetv.settextcolor(color.blue); valuetv.setclickable(true); valuetv.setonclicklistener(new view.onclicklistener() { public void onclick(view v) { imgarraylist = null; new getalb(adob[2].tostring().trim()).execute(); if (!strimgurls[0].tostring().equals("0")) { (int j = 0; j <= strimgurls.length - 1; j++) { string[] tmpimgurls = strimgurls[j].tostring() .split("_"); string extn = strimgurls[j] .tostring() .trim() .substring( strimgurls[j].tostring().trim() .lastindexof(".")); string fname = strimgurls[j].tostring().trim() .replace(extn, "_b" + extn); string temp = methods.albimg.trim() + tmpimgurls[1].tostring() + "/" + tmpimgurls[2].tostring() + "/" + tmpimgurls[3].tostring() + "/" + fname.trim(); imgarraylist.add(temp.trim()); } string[] imgulls = imgarraylist .toarray(new string[imgarraylist.size()]); intent = new intent(albums.this, imagegridactivity.class); i.putextra("imgurls", imgulls); startactivity(i); } } }); lnrlayout.addview(valuetv); } }
Comments
Post a Comment