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

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

Fragment onCreate examples from Open Source projects
This code example shows how to use the following methods: onCreate
	private ListView activityList;
	ActivitiesAdapter adapter;
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	} 
	 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		final View v = inflater.inflate(R.layout.fragment_profileactivity, null);
		activityList = (ListView) v.findViewById(R.id.profile_details_activitylist);
		if (adapter != null) {
			displayActivities(); 
		} 
		return v;
	} 
	 
	public void setActivitiesAndUser(Context context, final ActivitiesResponse[] activities, UserDetails user ) {
		// Set the activities, create the adapter 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getArguments, onCreate
        /** 
         * When creating, retrieve this instance's number from its arguments. 
         */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mNum = getArguments() != null ? getArguments().getInt("num") : 1;
        } 
 
        /** 
         * The Fragment's UI is just a simple text view showing its 
         * instance number. 
         */ 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.hello_world, container, false);
            View tv = v.findViewById(R.id.text);
            ((TextView)tv).setText("Fragment #" + mNum);
            tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb));
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getArguments, onCreate
        /** 
         * When creating, retrieve this instance's number from its arguments. 
         */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            mNum = getArguments() != null ? getArguments().getInt("num") : 1;
        } 
 
        /** 
         * The Fragment's UI is just a simple text view showing its 
         * instance number. 
         */ 
        @Override 
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View v = inflater.inflate(R.layout.hello_world, container, false);
            View tv = v.findViewById(R.id.text);
            ((TextView)tv).setText("Fragment #" + mNum);
            tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb));
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: onCreate, setRetainInstance
 
   public ImageCacheFragment(){} 
 
   @Override 
   public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setRetainInstance(true);
   } 
} 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: onCreate
    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()");
  } 
 
  @Override 
  public void onStart() { 
    super.onStart(); 
    Log.d(getClass().getSimpleName(), "onStart()");
  } 
Full Snippet Info
7
CodeRank
Related Fragment onCreate Questions & Answers:
onCreate Method Overview
Called to do initial creation of a fragment.
See Code Examples for other Android Fragment Methods: