public void onAttach(Activity activity) { onAttach(activity); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception try { mListener = (AdapterListener) activity; } catch (Exception e) { throw new Exception(activity.ToString() + " must implement OnHeadlineSelectedListener"); } }
/// <summary> /// Make sure the activity has implemented OnFragmentUpdateListener /// </summary> /// <param name='activity'> /// Our activity /// </param> public override void OnAttach(Activity activity) { base.OnAttach(activity); try { mCallback = activity as OnFragmentUpdateListener; } catch(InvalidCastException ex) { throw new InvalidCastException(activity.ToString() + " must implement OnFragmentUpdateListener"); } }