I made the following code to retrieve data from a SQLite database.
public Cursor fetchAllScores() { return database.query(DATABASE_TABLE, new String[] { KEY_ROWID, KEY_PLAYDATE, KEY_NUMVALA, KEY_NUMVALB }, null, null, null, null, null); }
Then I call this function in main.java using the following
cursor = dbHelper.fetchAllScores(); startManagingCursor(cursor);
After entering the cursor, I managed to populate myGridView with some data using the following code
GridView myGV = (GridView)findViewById(R.id.gridView1); String[] cols = new String[] { scoreDbAdapter.KEY_PLAYDATE, scoreDbAdapter.KEY_NUMVALA, scoreDbAdapter.KEY_NUMVALB}; int[] views = new int[] { android.R.id.text1, android.R.id.text2, android.R.id.text2 }; SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_1, cursor, cols, views); Log.w("NumRows",adapter.getCount() + ""); myGV.setAdapter(adapter);
Now the problem is only to fill the first row and the first two columns, I want the data to be both in the forst row (2011-10-27, 5, 6), and in the second row (2011-10-26, 3, 2 ) but im getting is only forst row like (2011-10-27, 2011-10-26).
Can this be fixed in a GridView?