java - Cannot resolve method 'setAdapter()' -
i have found several questions similar one, none of them fix issue. here code have written -
databasehelper databasehelper; arrayadapter<string> madapter; listview noteslist; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); databasehelper = new databasehelper (this); noteslist = (listview) findviewbyid(r.id.noteslist); loadnoteslist (); } public void loadnoteslist () { arraylist<string> noteslist = databasehelper.getnamelist(); if (madapter == null) { madapter = new arrayadapter<string>(this, r.layout.row, r.id.note_name, noteslist); noteslist.setadapter(madapter); } else { madapter.clear(); madapter.addall(noteslist); madapter.notifydatasetchanged(); } } ...
my code seems code in tutorial following, , code seems in correct place, know missing or did wrong, because android studio gives me error-
cannot resolve method 'setadapter(android.widget.arrayadapter<java.lang.string>)'
does see did wrong, or might need add or change? thank you!
you have introduced local variable noteslist
inside loadnoteslist
function:
arraylist<string> noteslist = databasehelper.getnamelist();
change name else.
Comments
Post a Comment