tags:

views:

151

answers:

2

hi. i am a newbie trying to learn android by doing a todo application. so far i have:

  • list all todos
  • create a todo(insert into database)

i need help adding a delete feature my xml structure for todo list is that i have a TableLayout. and to display my todo list, i put my todo in a textview and i put that textview into a tablerow and i put that tablerow into my tablelayout.

now i want to add a delete button to the right of my todo list. my question is is there a default delete button that i can use? how do i handle the onclick event, i mean like if a click on a delete button, how do i know which todo this button is for? and is my layout correct?

+2  A: 

Common Tasks and How to Do Them in Android

Pentium10
+1  A: 

I think using a TableLayout is probably not the right way to do this. If you use a ListView, it can automatically handle adding rows when more information is added to the database, refreshing the list when information is changed, and accepting user clicks. However, a ListView is a bit more complicated to use since you have to use a ListAdapter. To be honest I've never tried creating a List directly out of an SQL database, but it's probably doable. I suggest you look for tutorials in ListViews (the ApiDemos example app Google distributes is a good place to see a few lists in action), and then look for examples binding a database to the list.

By the way, you should have a look at whether you can improve your accept rate of 38% - that's a bit low particularly for someone who has 1k rep.

Steve H
thanks. no idea what accept rate is.
Funky Dude
No problem. Your "accept rate" is the percentage of questions for which you have accepted an answer, and is displayed below your name when you ask a question. So according to that number, you've only accepted an answer on about a third of your questions. While it's possible that you simply haven't had good answers, it's more likely that you just forgot to click the accept tickmark. (I note that you did upvote and accept this answer, so thanks!) It's not that big a deal I suppose, but it means people who've tried to help you in the past didn't get any "reputation" for it.
Steve H