Code example for Fragment

Methods: getActivity

	private void addExampleFragment() { 
		// create a new fragment 
		Fragment f = new ExampleFragment();
		// get the activity and add the new fragment after this one! 
		Activity a = getActivity();
		if (a != null && a instanceof FragmentLauncher)
			((FragmentLauncher) a).addFragment(ExampleFragment.this, f);
	public ExampleFragment() { 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		parentView = inflater.inflate(R.layout.example_fragment, container, false);
Contextual code suggestions in your IDE  Get Codota for Java