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

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: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, onSaveInstanceState
            mPlaylistAdapter.changeCursor(null);
    } 
 
    @Override 
    public void onSaveInstanceState(Bundle outState) {
        outState.putAll(getArguments() != null ? getArguments() : new Bundle());
        super.onSaveInstanceState(outState);
    } 
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
 
        AdapterContextMenuInfo mi = (AdapterContextMenuInfo)menuInfo;
 
        menu.add(0, PLAY_SELECTION, 0, getResources().getString(R.string.play_all));
 
        if (mi.id >= 0) {
            menu.add(0, RENAME_PLAYLIST, 0, getResources().getString(R.string.rename_playlist));
            menu.add(0, DELETE_PLAYLIST, 0, getResources().getString(R.string.delete_playlist));
        } 
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
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:getArguments, getFragmentManager, isAdded
            // the view hierarchy; it would just never be used. 
            return null; 
        } 
 
        if (getShownIndex() >= mQuickShare.getFeed().size()) {
            if (isAdded()) getFragmentManager().beginTransaction().remove(this).commit();
            return null; 
        } 
 
        Log.d(TAG, "[onCreateView]");
 
        View v = inflater.inflate(R.layout.story_detail_webview, container, false);
 
        Button mShareStory = (Button) v.findViewById(R.id.share_button);
        mShareStory.setOnClickListener(this);
 
        mWebView = (WebView) v.findViewById(R.id.story_webview);
 
        Log.d(TAG, "[onCreateView] url: loading the current story");
 

6
CodeRank
getArguments Method Overview
Return the arguments supplied when the fragment was instantiated, if any.
See Code Examples for other Android Fragment Methods: