title | type | duration | creator | ||||
---|---|---|---|---|---|---|---|
Cursor Adapters - Grocery List |
lab |
1:25 |
|
Note: This can be a pair programming activity or done independently.
In this lab, you will be displaying a list of grocery items from a SQLite database using a CursorAdapter
. Each grocery item has a name, description, price, and type. On this screen, you will only be showing the name of each item.
- Extend and complete the SQLiteOpenHelper class to query the database for all of the grocery items
- Make a ListView to display the grocery items
- Use a CursorAdapter to display the queried grocery items
Bonus:
- Create a custom layout for the ListView item to show more info from the database
The starter-code
folder contains an Android project with the following:
- A MainActivity.java file that prepopulates the database
The screenshot below shows what the app should look like.
- Create a Detail View activity for your list
- Your Detail View activity should be called via an Intent in an
OnItemClickListener()
- Your Detail View should render individual data about each item in your table:
- ITEM_NAME
- DESCRIPTION
- PRICE
- TYPE
CREATE TABLE SHOPPING_LIST(_id INTEGER PRIMARY KEY AUTOINCREMENT,
ITEM_NAME TEXT,
DESCRIPTION TEXT,
PRICE TEXT,
TYPE TEXT);
Released under the Creative Commons Non-Commercial License