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

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 
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));
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));
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);
   } 
} 
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()");
  } 
7
CodeRank
This code example shows how to use the following methods:getArguments, onCreate
     * Populate image using a url from extras, use the convenience factory method 
     * {@link ImageDetailFragment#newInstance(String)} to create this fragment. 
     */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mImageUrl = getArguments() != null ? getArguments().getString(IMAGE_DATA_EXTRA) : null;
    } 
 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate and locate the main ImageView 
        final View v = inflater.inflate(R.layout.image_detail_fragment, container, false);
        mImageView = (ImageView) v.findViewById(R.id.imageView);
        return v;
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
6
CodeRank
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));
7
CodeRank
This code example shows how to use the following methods:getArguments, onCreate, setRetainInstance
	private OpenRocketSaverTask task;
	private OnOpenRocketFileSaved listener;
	 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setRetainInstance(true);
		Bundle b = getArguments();
		if ( b != null ) {
			showProgressDialog = b.getBoolean(SHOW_PRGRESS_DIALOG_ARG, true);
		} 
		if ( task == null ) {
			// since we retain instance state, task will be non-null if it is already loading. 
			task = new OpenRocketSaverTask();
			task.execute();
		} 
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
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(android.R.id.text1);
            ((TextView)tv).setText(mNum > 0 ? "Fragment #" + mNum : "Base");
            tv.setBackgroundDrawable(getResources().getDrawable(android.R.drawable.gallery_thumb));
7
CodeRank
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()).getPersonItem(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));
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: