android - Filling list view from multiple columns in a cursor, but only one row? -


sorry if seems stupid, i'm sort of new stuff. situation have lot of data stored in database need present in list views. first view pulls 15 rows , uses 2 out of 14 columns in db. use adapter present in list view:

private class customlistadapter extends simplecursoradapter {      private cursor cursor;      public customlistadapter(context context, int textviewresourceid, cursor cursor, string from[], int to[]) {             super(context, textviewresourceid, cursor, from, to);             this.cursor = cursor;     }     @override     public view getview(int position, view convertview, viewgroup parent) {         view v = convertview;             if (v == null) {                 layoutinflater vi = (layoutinflater)getsystemservice(context.layout_inflater_service);                 v = vi.inflate(r.layout.row, null);             }             cursor.movetoposition(position);             if (cursor != null) {                     textview lt = (textview) v.findviewbyid(r.id.lefttext);                     textview rt = (textview) v.findviewbyid(r.id.righttext);                     if (lt != null) {                           lt.settext(/*cursor.getstring(cursor.getcolumnindex(ewstablecontentprovider.timestamp))*/cursor.getstring(cursor.getcolumnindex(ewstablecontentprovider._id)));                            }                     if (rt != null){                           rt.settext(cursor.getstring(cursor.getcolumnindex(ewstablecontentprovider.totalews)));                     }              }             return v;     } } 

}

this may stupid, @ least works. now, on next activity need present data columns, row user selected on previous activity. looking @ putting inside list view 1 http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/, modified adapter from. way, put data 2 fields in db each item in list view. perfect, 1 data point , comment goes it. problem @ point have 1 row in cursor, bit after @override executed once, instead of 7 items in list view, one. i'd appreciate help, if in entirely different way.

assuming know number of columns, use loop iterate through columns, storing each string string array.

string[] arr = new string[cursor.getcolumncount()]; for(int i=0; < cursor.getcolumncount(); i++)     arr[i] = cursor.getstring(i); 

then use string[] arrayadapter listview.


Comments