R
R
Rozag2015-03-26 16:21:43
Java
Rozag, 2015-03-26 16:21:43

Do I correctly define object id for Android list items?

I develop for Android and often in my applications I need to get some kind of object id for list items. Let me explain: I'm scrolling through the list of contacts, I clicked on Vasya, I want to get his unique id, under which this Vasya is stored in my database on some distant server. Usually I do the following: in the xml file for list items I include a TextView with vidibility = GONE, and I get the necessary data from it using getText(). A question for connoisseurs: how bad is it and how to do such things beautifully?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Copperfield, 2015-03-26
@Rozag

You must have passed an array of contact objects to your list adapter.
So take the desired object from this array and ask him for its id.
The desired object from the array can be obtained by its position in the list.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question