Best code examples for Fragment onAttach method (android.app.Fragment.onAttach)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment onAttach method.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Fragment onAttach examples from Open Source projects
This code example shows how to use the following methods: onAttach
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
    } 
 
    @Override 
    public void onDetach() { 
        mActivity = null;
        super.onDetach(); 
    } 
 
    @Override 
    public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
        onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
    } 
 
    @Override 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: onAttach
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
    } 
 
    @Override 
    public void onDetach() { 
        mActivity = null;
        super.onDetach(); 
    } 
 
    @Override 
    public final void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater) {
        onCreateOptionsMenu(new MenuWrapper(menu), mActivity.getSupportMenuInflater());
    } 
 
    @Override 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: onAttach
    ((DynamicFragmentsDemoActivity)getActivity()).showOther(v);
  } 
   
  @Override 
  public void onAttach(Activity a) {
    super.onAttach(a);
    Log.d(getClass().getSimpleName(), "onAttach()");
  } 
   
  @Override 
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(getClass().getSimpleName(), "onCreate()");
  } 
   
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Log.d(getClass().getSimpleName(), "onActivityCreated()");
  } 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getActivity, onAttach
        super.onCreate(savedInstanceState);
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
 
        // This is the fragment that launches the Janrain sharing dialogue 
        // If Android restarts the app and restores the activity stack with this fragment 
        // on top then the Janrain library needs to be re-initialized. 
        QuickShare.getInstance().initJREngage(getActivity());
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (container == null) {
            // We have different layouts, and in one of them this 
            // fragment's containing frame doesn't exist.  The fragment 
            // may still be created from its saved state, but there is 
            // no reason to try to create its view hierarchy because it 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: onAttach
 
    protected Context context;
     
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        context = activity.getApplicationContext();
    } 
     
} 
Full Snippet Info
6
CodeRank
onAttach Method Overview
Called when a fragment is first attached to its activity.
See Code Examples for other Android Fragment Methods: