DialogFragment 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 DialogFragment 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 
7
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 
7
CodeRank
This code example shows how to use the following methods:onAttach
 
        @Override 
        public void onAttach(Activity activity) {
            transcript.add("onAttach");
            onAttachActivity = activity;
            super.onAttach(activity);
        } 
 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            transcript.add("onCreate");
            super.onCreate(savedInstanceState);
        } 
 
        @Override 
        public Dialog onCreateDialog(Bundle savedInstanceState) {
            transcript.add("onCreateDialog");
            return returnThisDialogFromOnCreateDialog == null
                    ? super.onCreateDialog(savedInstanceState)
                    : returnThisDialogFromOnCreateDialog;
7
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 
6
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 
6
CodeRank
This code example shows how to use the following methods:onAttach
	private Activity activity;
	private Account account;
 
	@Override 
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		this.activity = activity;
	} 
 
	@Override 
	public Dialog onCreateDialog(Bundle args) {
		AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		builder.setTitle(R.string.select_account);
		final Account[] accounts = AccountManager.get(activity)
				.getAccountsByType("com.google");
		final int size = accounts.length;
		String[] names = new String[size];
		for (int i = 0; i < size; i++) {
			names[i] = accounts[i].name;
		} 
6
CodeRank
This code example shows how to use the following methods:onAttach
        return dialog;
    } 
     
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        context = activity.getApplicationContext();
    } 
     
    @Override 
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        ProgressDialog dialog = new ProgressDialog(getActivity());
        dialog.setMessage(getMessage());
        dialog.setCancelable(true);
        return dialog;
    } 
     
    private String getMessage() {
        int messageId = getArguments().getInt(MESSAGE);
        return context.getResources().getString(messageId);
5
CodeRank
This code example shows how to use the following methods:onAttach
        setRetainInstance(true);
    } 
     
    @Override 
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        try { 
            callbacks = (ReleaseSelectionCallbacks) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString() + " must implement "
                    + ReleaseSelectionCallbacks.class.getSimpleName());
        } 
    } 
     
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        release = callbacks.getReleasesInfo();
        if (release != null) {
            releaseList.setAdapter(new ReleaseInfoAdapter(getActivity(), R.layout.list_release, release));
5
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 
5
CodeRank
This code example shows how to use the following methods:onAttach
	private Context mContext;
	private LayoutInflater mInflater;
 
	@Override 
	public void onAttach(Activity activity) {
		super.onAttach(activity);
 
		mContext = activity.getApplicationContext();
		mInflater = activity.getLayoutInflater();
	} 
 
	/** 
	 * ライフサイクルに影響されないContextを返します。<br> 
	 * {@link #getActivity()} はライフサイクル次第でnullになるので。<br> 
	 * ただし、ApplicationContextなので、Viewの引数にすると、テーマが適用されなくなるかも。 
	 * 
	 * @return {@link Context} 
	 */ 
	protected Context getContext() {
		return mContext;
4
CodeRank
onAttach Method Overview
Called when a fragment is first attached to its activity.
See Code Examples for other Android DialogFragment Methods: