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

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

Fragment getArguments examples from Open Source projects
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: 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) {
Full Snippet Info
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));
Full Snippet Info
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,
Full Snippet Info
7
CodeRank
Related Fragment getArguments Questions & Answers:
getArguments Method Overview
Return the arguments supplied when the fragment was instantiated, if any.
See Code Examples for other Android Fragment Methods: