I'm displaying a ListView that I filled with a custom ListAdapter, called LazyAdapter, which code comes from here : http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/. The LazyAdapter uses my custom objects "EventData". I managed to display my List as I wanted, but now I'd like to get the clicked object. I found some help on other questions (here, here, and there), and wrote that code:
private OnItemClickListener mEventClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
EventData selectedEvent = (EventData) eventsListView.getItemAtPosition(arg2);
};
However, I get a cast error at execution.
05-14 17:10:46.718: E/AndroidRuntime(3863): java.lang.ClassCastException: java.lang.Integer
I also tried this similar solution:
EventData selectedEvent = (EventData) av.getItemAtPosition(arg2);
I got the same cast error. I don't know how I can get my Object EventData in an other way.
Thanks for your help!