i'm able populate sqlite db , crud operations. populate listview starting from:
list<starred> data = dbadapter.getalluserdata(); by log can read list:
for (starred st : data) log.d("title: ", "title: " + st.getname()); i'm pretty sure i'm missing adapter don't know how start.
this getalluserdata() function:
public static list<starred> getalluserdata() { list<starred> starredlist = new arraylist<starred>(); // select query string selectquery = "select * " + user_table; final sqlitedatabase db = open(); cursor cursor = db.rawquery ( selectquery, null ); if (cursor.movetofirst()) { { starred data = new starred(); data.setid(integer.parseint(cursor.getstring(0))); data.setname(cursor.getstring(1)); data.setlabel(cursor.getstring(2)); // adding contact list starredlist.add(data); } while (cursor.movetonext()); } return starredlist; i tried with
listview lv = (listview) findviewbyid(r.id.list); arrayadapter<starred> arrayadapter = new arrayadapter<starred>( this, android.r.layout.simple_list_item_1, data); lv.setadapter(arrayadapter);
but nullpointer exception. give me suggestion? appreciated.
try use cursor adapter pal https://github.com/codepath/android_guides/wiki/populating-a-listview-with-a-cursoradapter
Comments
Post a Comment