> I am creating a database driven app for managing people. I am showing > a list of people with each name in a TextView. When a TextView is > clicked, I launch a new intent to show the detail for the person. > > My question: What's the best practices for passing the id of the > person to the new intent? The TextView is displaying the name of the > person, so how do I know the id of the person? Once I know the id, I > know how to pass it to the new intent, but I don't know what the best > way to associate the id of the person to the TextView. Is there a > best practice for this?
If you use a ListView with a CursorAdapter, you will have the _ID of the database row supplied to you in onListItemClick(). If, for some reason, you do not wish to use ListView, you could put the _ID of the database row in the TextView's "tag" via setTag(), then retrieve it upon a click via getTag(). -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---