Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Our ToDo list application is working quite well, but we only have a single row of sample data in it. Let's add a few more tasks. We now have several tasks, now if we go through and mark a few as completed, you'll start to see the need to perhaps have some filtering. I think it would be handy to be able to show just the tasks that are left to do, just the ones that are completed, or all the tasks. Right now we're always showing all the tasks. So let's implement this. To get started let's go to the task class. Right now our get all method is responsible for getting all the tasks from the database. Let's add a filter to this. We specify a default value so you don't have to call get all with the filter parameter. Our filter will simply be an addition to the where clause. If the filter was specified, we will add it to the where. Now let's go to the ToDo window and use this filter in the load task method. We will again specify the default value and now we will pass in the filter to the get all method. This doesn't change anything. If you run the app we will see that once we fix any typos. All the tasks are still displayed as they were before. So let's go back to the ToDo window and look at the UI. Let's shrink the list and add a new control above it to select what we want to see. We will use the segmented control. We will have an entry for what's left to do, what's completed, and all tasks. We will call this the filter segment. Line it up a little better here. Now let's look at the code. Here the action event for the segment specifies as a parameter which button was clicked. Now we can call our load task method using the filter to only show the tasks we want. The all button will show all tasks like it does today, so that does not need a filter. The completed button will load the tasks where completed is true, also equal to one in the case of SQLite. And for the tasks that are remaining to be done, completed will be equal to zero. Now let's run our project. You can see all is selected, we still see all the rows, if we click to do the completed ones have disappeared from the list, if we click completed, only the completed ones now show. Our filter is now complete.
| Course: | Real Studio |
| Author: | Paul Lefebvre |
| SKU: | 34190 |
| ISBN: | 1-936334-77-1 |
| Release Date: | 2011-02-02 |
| Duration: | 7 hrs / 87 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |