Code example for ListFragment

Methods: onAttach

0
    } 
 
    @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 = (OnHeadlineSelectedListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnHeadlineSelectedListener"); 
        } 
    } 
 
    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        // Notify the parent activity of selected item 
        mCallback.onArticleSelected(position);