14.01.2011 0:02, Tobiah пишет:
Now, if I keep a representation of the data set somewhere else in an
array, then
I could index that array by the position parameter.
The "position" parameter is the position within the adapter, it's the
same value passed to getView().
I'd like to get the information
from the parameters to the event handler though. Right now, the 'id'
param mirrors
the position parameter. Is that something that I can set somewhere?
Yes, override YourAdapter.getItemId() and return whatever you need. Can
be the "_id" value from the database or anything else.
There is another very useful override - YourAdapter.getItem() which is
supposed to return the data object for that position. You can get the
value outside of your adapter, by calling ListView.getItemAtPosition().
Note that if your data actually comes from a database, you could just
use a CursorAdapter to avoid copying data into a memory array.
Otherwise,
it's ugly, but I could glean the information from the text that is
displayed in
each row. How would I do that given the 'parent' or 'view' parameter.
There is also the occasionally useful View.setTag / getTag that lets you
associate your own arbitrary data object with any View, and later get
the value back somewhere else.
You could use setTag() inside your adapter's getView(), then use it
somewhere else, as needed.
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en