Need some help with getting the listener to work with my listview. My activity is extending activity. This could be completely wrong. I've been mixing and matching. Any help would be awesome.
lv.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parentView, View childView, int position, long id) {
Toast.makeText(getBaseContext(), "u clicked " + al.get(position),Toast.LENGTH_LONG).show();
}
});
You need to get the position from the view.
This relies on you having set a type for the list (MyType), it also requires whatever type you are using has overridden the toString().
This works because the ListView is able to return a listitem at any given position, in your code you are using al, I'm guessing this is to refer to the arraylist, you need I think to get the item at that position in the listview. (lv)