android - SimpleCursorAdapter - modify data before load into ListView -


i have simplecursoradapter populates data form sqlite database. it's working fine, "duration" column given in milliseconds , divide (duration / 1000) before displaying. possible without storing duration (in minutes) column in db?

adapter:

 adapter = new simplecursoradapter(getactivity(),  r.layout.rec_list_items,  db.selectallrecords(),  new string[] { "day", "hour", "minute", "duration", "link" },  new int[] { r.id.textview_day, r.id.textview_hour, r.id.textview_minute, r.id.textview_duration, r.id.textview_link },  cursoradapter.flag_register_content_observer); 

selectallrecords:

public cursor selectallrecords() {     string[] cols = new string[] {id, day, hour, minute, duration, link};     cursor mcursor = database.query(true, table,cols,null             , null, null, null, null, null);     if (mcursor != null) {         mcursor.movetofirst();     }      return mcursor; } 

you have couple of options here:

one create custom simplecursoradapter , override setviewtext(). in implementation check if textview in question passed , set view value desire. have convert string int (or float, need) apply precision.

another 1 implement simplecursoradapter.viewbinder, set binder in adapter's setviewbinder , thing in binder's setviewvalue


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -