p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 (http://p2p.wrox.com/forumdisplay.php?f=432)
-   -   Chapter 6 Todo List removeItem (http://p2p.wrox.com/showthread.php?t=73005)

abowman March 1st, 2009 09:44 PM

Chapter 6 Todo List removeItem
 
To get removeItem to work correctly in chapter 6, add the id field to the ToDoItem class (create a getID function and also update the constructor to accept the id). When the items are created in updateArray, get the id and pass it to the new ToDoItem as you do for the task and date. Now, when you want to remove an item, you can get the id of the item and pass it to the removeItem function (delete the code that inverses the index).

MMC2 May 18th, 2009 09:07 AM

Remove Item chapter 6 To Do Example
 
I have entered the code for the example. At each step it worked. After the last step it worked briefly, even remove item worked. Then the whole lot crashed and I can't get eclipse to even load the app now. I have posted about this. When I get going again I would like to follow your tips about remove item, but I don't know how to do the things you have said. Would you be able to provide the specific code changes please?

sierawsk May 18th, 2009 10:14 AM

You shouldn't have to make those changes to the ToDoList example. My app works fine removing items. Does it cause yours to crash?

MMC2 May 18th, 2009 09:17 PM

Remove Item chapter 6 To Do Example
 
Thanks Sierawsk. After turning the computer off overnight, Eclipse will now run the app. Mostly remove item doesn't work but occasionally it will remove an item, but the wrong item.

Mike

Powersword February 5th, 2010 11:18 AM

Chapter 6 Todo List removeItem
 
Hi guys

I am new to this. I noticed that the last message was posted sometime ago. Just want to know if the problem was solved because I am encountering the same problem.

Anyway I have found out that the reason why sometimes the "remove" worked and sometimes it won't. It is due to the SQLite Database having a different row Id value compared with the chosen menu item position value. The row ID of the database only increases. It won't decrease even if the item is removed. So for example after 100 clicks the row ID in the DB will have increased to 100. If your list happen to have for e.g 6 items. Passing in the positions of this 6 items (value of 1 to 6) may not necessary match to row ID of the DB where this 6 items are stored.

One way to solve this is as mentioned to store the row ID used by SQ Lite database in the item. However I can't see how it can be done yet.

Appreciate if anyone has any suggestions. [:)]


All times are GMT -4. The time now is 07:21 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.