Thursday, July 3, 2014

Building the Home Screen Custom List with SQLite

Reflecting on how I want my list to display this morning and I'd like to do a little work on the home page list view. It should show the soonest to be started subtask on the master list, the time it's going to start and whether there is a reminder attached to that time displayed and easily edited (check box calendar control), and tasks should have a status. Because sometimes a project is on hold because you are waiting for something beyond your control. If this is the case, I want the status to indicate this fact and somehow a time limit or a way to change this status.

While I'm creating this custom ListView I decided to go ahead and get the sqlite database going as well. I read on the Android developer site for an hour or so to get an idea of what I am doing. I finally settled once again on this excellent tutorial which describes how to do asynchronous queries on the database and has a clear to follow narrative on how everything works.

Excellent Vogella Tutorial

I am doing the Vogella tutorial, I also want to utilize Fragments, Eclipse put those in for me


As I'm doing the tutorial, I am recrafting the code to fit into my project and will utilize Fragments in the hope that I can make the orientation and tablet layouts cool later.

Step 1: Created a project with a main activity, I renamed the main acitivity MainProjectList. This created a .java source file called MainProjectList.java, and two .xml files, one for the activity layout and one for the fragment.

Step 2: To stay in line with the Vogella tutorial, I am going to also create a details activity, this would show the detail view of a project. This is a little ahead of where I'm at in concept (haven't even thought of what the detail of a project item should look like yet), but that's OK. I right clicked and added an activity called ProjectItemDetail.

Adding the activity also adds a layout and a fragment .xml file, cool!
Step 3: Create a package for the database classes com.malevolentmare.taskstarter.database.

Step 4: Add a class to represent the Project table. This table will hold individual records that represent a project. I will have to put some thought into what fields I want this table to have, I will also have to look at some SQLite documentation online.

Step 4 is going to warrant its own blog post because I have to consider what fields I want in a database. I know from my limited experience that changing this can be a pain. If you change the structure of an SQLite database, you will find yourself having to uninstall and reinstall your app for testing, after a series of inexplicable crashes.





No comments:

Post a Comment