android - ListView null pointer exception when accessing the editText in its children -
i having problem on getting value of edittext in listview. logcat says have nullpointerexception. in doing research found out on code getting index of visible child of listview. can me one? want value of edittext in listview. here code
sqlitedatabase db = databasehandler.getwritabledatabase(); db.begintransaction(); int counter = 0; for(hashmap<string, string> map : mylist) { contentvalues cv = new contentvalues(); string string = ""; (int = 0; < lv_attachedfiledata.getcount(); i++) { if (i == counter) { view view=lv_attachedfiledata.getchildat(i); edittext edittext=(edittext) view.findviewbyid(r.id.txt_idesc); string = edittext.gettext().tostring(); cv.put(constants.attach_reportcode, reportcode); cv.put(constants.attach_filename, map.get(file_name)); cv.put(constants.attach_description, string); cv.put(constants.attach_filelocation, map.get(file_uri)); cv.put(constants.attach_createdby, map.get(uploaded_by)); cv.put(constants.attach_datecreated, map.get(date_uploaded)); db.insert(constants.table_attach, null, cv); } } counter++; } db.settransactionsuccessful(); db.endtransaction(); db.close();
here logcat:
07-22 10:18:43.000: e/androidruntime(9001): fatal exception: main 07-22 10:18:43.000: e/androidruntime(9001): java.lang.nullpointerexception 07-22 10:18:43.000: e/androidruntime(9001): @ ph.com.ex.ireport.s_10th_ireportmain$6.onclick(s_10th_ireportmain.java:597) 07-22 10:18:43.000: e/androidruntime(9001): @ android.view.view.performclick(view.java:3131) 07-22 10:18:43.000: e/androidruntime(9001): @ android.view.view$performclick.run(view.java:12035) 07-22 10:18:43.000: e/androidruntime(9001): @ android.os.handler.handlecallback(handler.java:587) 07-22 10:18:43.000: e/androidruntime(9001): @ android.os.handler.dispatchmessage(handler.java:92) 07-22 10:18:43.000: e/androidruntime(9001): @ android.os.looper.loop(looper.java:132) 07-22 10:18:43.000: e/androidruntime(9001): @ android.app.activitythread.main(activitythread.java:4123) 07-22 10:18:43.000: e/androidruntime(9001): @ java.lang.reflect.method.invokenative(native method) 07-22 10:18:43.000: e/androidruntime(9001): @ java.lang.reflect.method.invoke(method.java:491) 07-22 10:18:43.000: e/androidruntime(9001): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:844) 07-22 10:18:43.000: e/androidruntime(9001): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:602) 07-22 10:18:43.000: e/androidruntime(9001): @ dalvik.system.nativestart.main(native method)
Comments
Post a Comment