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 
Experience pair programming with AI  Get Codota for Java