Android: arrayAdapter throwing null pointer exception? -
i'm having issues array adapter.
this in lessonnoteslist class:
mydb = new dbhelper(this); //creating arraylist of contacts data arraylist array_list = mydb.getalllessonnotes(); //creating array adapter manipulate contacts data listview arrayadapter arrayadapter = new arrayadapter(this,r.layout.list_layout, array_list); //adding contacts list view. lessonnote = (listview)findviewbyid(r.id.listview1); lessonnote.setadapter(arrayadapter); //setting onclicklistener process user's actions lessonnote.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { // todo auto-generated method stub //prepare data listview item passed new activity //arg2 increased 1 0 based index contacts table in database works of base index of 1 int id_to_search = value; //bundle extras = getintent().getextras(); bundle databundle = new bundle(); databundle.putint("id", id_to_search); log.d("id ^&*: ", string.valueof(id_to_search)); //create new intent open displaycontact activity intent intent = new intent(getapplicationcontext(), com.example.ltss.dyslexia.app.lessonnotes.class); intent.putextras(databundle); startactivity(intent); } }); dbhelper class:
public arraylist getalllessonnotes() { arraylist array_list = new arraylist(); sqlitedatabase db = this.getreadabledatabase(); cursor res = db.rawquery( "select * "+table_lesson_notes, null); res.movetofirst(); while(res.isafterlast() == false) { array_list.add(res.getstring(res.getcolumnindex(date))); res.movetonext(); } return array_list; } the code crashes null pointer exception here:
lessonnote.setadapter(arrayadapter); any ideas why happening? i've tried debugging , debugger telling me arrayadatper contains 1 entry should
i have same code different page , it's working 100% fine..
any suggestions welcome!
thanks
are sure line ?
lessonnote = (listview)findviewbyid(r.id.listview1); it seems in layout xml, no view have "listview1" id.
Comments
Post a Comment