Fragment getActivity - 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 getActivity method.

This code example shows how to use the following methods: getActivity
		return v;
	} 
 
	@Override 
	public void changedState(int state) {
		((StateChangedListener) getActivity()).changedState(state);
	} 
	 
	public void setState(int state) {
		button.setState(state);
	} 
 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, getResources
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		if (savedInstanceState != null)
			mColorRes = savedInstanceState.getInt("mColorRes");
		int color = getResources().getColor(mColorRes);
		// construct the RelativeLayout 
		RelativeLayout v = new RelativeLayout(getActivity());
		v.setBackgroundColor(color);		
		return v;
	} 
	 
	@Override 
	public void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		outState.putInt("mColorRes", mColorRes);
	} 
	 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, onActivityCreated, setRetainInstance
    return(result);
  } 
 
  @Override 
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
 
    setRetainInstance(true);
    getActivity().getApplicationContext()
                 .bindService(new Intent(
                                         "com.commonsware.android.advservice.IScript"), 
                              this, Context.BIND_AUTO_CREATE);
  } 
 
  @Override 
  public void onDestroy() { 
    getActivity().getApplicationContext().unbindService(this);
 
    super.onDestroy(); 
  } 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, getView, onActivityCreated
    /** 
     * Attach to list view once Fragment is ready to run. 
     */ 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ensureList(); 
    } 
 
    /** 
     * Detach from list view. 
     */ 
    @Override 
    public void onDestroyView() { 
        mHandler.removeCallbacks(mRequestFocus);
        mList = null;
        super.onDestroyView(); 
    } 
 
    /** 

9
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, onActivityCreated, startActivity
		return inflater.inflate(R.layout.splash, container, false);
	} 
 
	@Override 
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		/* Found credentials, forwarding to BrowsingActivity */ 
		SharedPreferences prefs = SettingsActivity.getSettings(getActivity());
		if (prefs.contains("ident")) {
			Intent browseData = new Intent(getActivity(), BrowsingActivity.class);
			String serverUrl = prefs.getString("serverUrl", "");
			browseData.putExtra("url", serverUrl + "/api/getFolderList");
			startActivity(browseData);
		} 
	} 
 
} 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity
            setHasOptionsMenu(true);
        } 
 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
            return new TextView(getActivity());
        } 
 
        @Override 
        public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
            menu.add("Test");
        } 
	     
	} 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, getChildFragmentManager
 
    return(result);
  } 
 
  private PagerAdapter buildAdapter() { 
    return(new SampleAdapter(getActivity(), getChildFragmentManager()));
  } 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, onDestroy
                              Context.BIND_AUTO_CREATE);
  } 
 
  @Override 
  public void onDestroy() { 
    getActivity().getApplicationContext().unbindService(this);
    disconnect(); 
 
    super.onDestroy(); 
  } 
 
  @Override 
  public void onClick(View view) {
    EditText script=(EditText)getView().findViewById(R.id.script);
    String src=script.getText().toString();
 
    service.executeScript(src);
  } 
 
  @Override 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity, getArguments, onCreate
    public PersonDetailFragment() { 
    } 
 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        if (getArguments().containsKey(ARG_ITEM_ID)) {
        	// Should use the contentprovider here ideally 
            mItem = DatabaseHandler.getInstance(getActivity()).getPerson(getArguments().getLong(ARG_ITEM_ID));
        } 
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_person_detail, container, false);
 
        if (mItem != null) {
            textFirstName = ((TextView) rootView.findViewById(R.id.textFirstName));
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getActivity
    return(result);
  } 
 
  @Override 
  public void onClick(View v) {
    ((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()");
  } 
   
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Fragment getActivity Questions & Answers:

Other Fragment getActivity Examples

11:	
12:	        // Create a new instance of DatePickerDialog and return it
13:	        return new DatePickerDialog(getActivity(), this, year, month, day);
14:	    }
15:

Read More

10:	
11:	        // Create a new instance of TimePickerDialog and return it
12:	        return new TimePickerDialog(getActivity(), this, hour, minute,
13:	                DateFormat.is24HourFormat(getActivity()));
14:	    }
-
11:	        // Create a new instance of TimePickerDialog and return it
12:	        return new TimePickerDialog(getActivity(), this, hour, minute,
13:	                DateFormat.is24HourFormat(getActivity()));
14:	    }
15:

Read More

getActivity Method Overview
Return the Activity this fragment is currently associated with.
See Code Examples for other Android Fragment Methods: