Code example for ListFragment

Methods: onAttach

    public void onAttach(Activity 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"); 
    public void onListItemClick(ListView l, View v, int position, long id) {
        // Notify the parent activity of selected item 
Stop searching for code, let great code find you!  Add Codota to your java IDE