Hello,

I working on an app that's reads a SQLite database and lists selected
rows as listViews inside a TableLayout. The problems is that I dont
know how to bind the row cursors to the listViews. Anyone how have don
such a thing?

Here is the relevant parts of my code

public class DataBaseHelper extends SQLiteOpenHelper {

        public static final String DB_ID = "_id";

        public Cursor fetchDistance(String Distance, int id) {
                return myDatabase.query(true,
                                Distance,
                                null,
                                DB_ID + "=" + id,
                                null, null, null, null, null);
        }

public class TimeSchedules extends Activity {

      int id;

     DataBaseHelper mDbHelper = new DataBaseHelper(this);

     Cursor distanceCursor = mDbHelper.fetchDistance("Race", id);
     startManagingCursor(distanceCursor);
     showRace(laptimeCursor, distanceCursor);

     }

    private void showRace(Cursor l) {

        if(l.moveToFirst()){

                RowCursorAdapter CursorAdapter = new RowCursorAdapter(this,
l);
                View view = (View) CursorAdapter.newView(this, l, new
TableLayout(this));
                setContentView(view);

        }

public class RowCursorAdapter extends ResourceCursorAdapter {

        public RowCursorAdapter(Context context, Cursor c) {
                super(context, R.layout.race_view, c);
        }

    @Override
    public View newView(Context context, Cursor c, ViewGroup parent) {
        LayoutInflater li =
(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = li.inflate(R.layout.race_view, parent, false);
        bindView(v, context, c);
        return v;

    }

    @Override
    public void bindView(View view, Context context, Cursor c) {
        ListView tvDistance = (ListView)
view.findViewById(R.id.list_distance);
        ListView tvLap_time = (ListView)
view.findViewById(R.id.list_lap_time);
        ListView tvTime = (ListView)
view.findViewById(R.id.list_time);

//      Here Im really unsure how to bind the rows to the listViews
//      fore textViews and a column cursor the code looks likes as
below.

 
tvDistance.set(c.getString(c.getColumnIndex(DataBaseHelper.DB_DISTANCE));
 
tvLap_time.setText(c.getString(c.getColumnIndex(DataBaseHelper.DB_TEMP_TIME)));
 
tvTime.setText(c.getString(c.getColumnIndex(DataBaseHelper.DB_FINISH_TIME)));

        }

}

Tanks fore reading this



-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to