SelectionListener Public Listener
package course.labs.notificationslab;
public interface SelectionListener {
public void onItemSelected(int position);
}
//Supporting Fragment class1
//field
private SelectionListener mCallback;
//onAttach m()
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// This makes sure that the container activity has implemented
// the callback interface. If not, it throws an exception
try {
mCallback = (SelectionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement SelectionListener");
}
}
@Override
public void onListItemClick(ListView l, View view, int position, long id) {
// Send the event to the host activity
mCallback.onItemSelected(position);
}
}