Fragment onAttach - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Fragment onAttach method.

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 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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()");
  } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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();
    } 
     
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getArguments, onAttach
		return view;
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mFeedObserver = new ContentObserver(new Handler(activity.getMainLooper())) {
            @Override 
            public void onChange(boolean selfChange) {
                onFeedUpdated(); 
            } 
        }; 
        mFeedUri = getArguments().getParcelable(ARG_FEED_URI);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        onFeedUpdated(); 
    } 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:onAttach
            contract = (T) activity;
        } catch (ClassCastException e) {
            throw new IllegalStateException(activity.getClass().getSimpleName() + " must implement "
                    + getClass().getSimpleName() + "'s contract interface.", e);
        } 
        super.onAttach(activity);
    } 
 
    @Override 
    public void onDetach() { 
        super.onDetach(); 
        contract = null;
    } 
 
    public final T getContract() { 
        return contract;
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:onAttach
    args.putInt(ARG_CONTENT_LEVEL, contentLevel);
    return args;
  } 
 
  @Override public void onAttach(Activity activity) {
    super.onAttach(activity);
    callback = (Callback) activity;
  } 
 
  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle args = getArguments();
    menuEntry = args.getString(ARG_MENU_ENTRY);
    contentLevel = args.getInt(ARG_CONTENT_LEVEL);
 
    setHasOptionsMenu(true);
  } 
 
  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:onAttach
    private View googleButton;
    private Activity mActivity;
 
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        mActivity = activity;
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.downloader_tab, container, false);
        amButton = v.findViewById(R.id.source_anymemo);
        feButton = v.findViewById(R.id.source_fe);
        ssButton = v.findViewById(R.id.source_ss);
        quizletButton = v.findViewById(R.id.source_quizlet);
        dropboxButton = v.findViewById(R.id.source_dropbox);
        googleButton = v.findViewById(R.id.source_google);
        amButton.setOnClickListener(this);
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:onAttach
	    setArguments(args);
	} 
	 
	@Override 
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		this.activity = activity;
	} 
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		layoutResourceId = getLayoutResId();
	} 
 
	/** 
	 * 获取布局文件资源ID 
	 * @return 布局文件资源ID 
	 */ 
	private int getLayoutResId(){ 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
onAttach Method Overview
Called when a fragment is first attached to its activity.
See Code Examples for other Android Fragment Methods: