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

This code example shows how to use the following methods:setArguments
 
	public static SuperAwesomeCardFragment newInstance(int position) {
		SuperAwesomeCardFragment f = new SuperAwesomeCardFragment();
		Bundle b = new Bundle();
		b.putInt(ARG_POSITION, position);
		f.setArguments(b);
		return f;
	} 
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		position = getArguments().getInt(ARG_POSITION);
	} 
 
	@Override 
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 
		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
7
CodeRank
This code example shows how to use the following methods:setArguments
 
    // Bundle 
    public GenresFragment() { 
    } 
 
    public GenresFragment(Bundle args) {
        setArguments(args);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // GenreAdapter 
        mGenreAdapter = new GenreAdapter(getActivity(), R.layout.listview_items, null,
                new String[] {}, new int[] {}, 0);
        mListView.setOnCreateContextMenuListener(this);
        mListView.setOnItemClickListener(this);
        mListView.setAdapter(mGenreAdapter);
 
        // Important! 
7
CodeRank
This code example shows how to use the following methods:setArguments
 
    // Bundle 
    public PlaylistsFragment() { 
    } 
 
    public PlaylistsFragment(Bundle args) {
        setArguments(args);
    } 
 
    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        // Adapter 
        mPlaylistAdapter = new PlaylistAdapter(getActivity(), R.layout.listview_items, null,
                new String[] {}, new int[] {}, 0);
        mListView.setOnCreateContextMenuListener(this);
        mListView.setAdapter(mPlaylistAdapter);
        mListView.setOnItemClickListener(this);
 
        getLoaderManager().initLoader(0, null, this);
7
CodeRank
This code example shows how to use the following methods:setArguments
  static EditorFragment newInstance(int position) {
    EditorFragment frag=new EditorFragment();
    Bundle args=new Bundle();
 
    args.putInt(KEY_POSITION, position);
    frag.setArguments(args);
 
    return(frag);
  } 
 
  static String getTitle(Context ctxt, int position) {
    return(String.format(ctxt.getString(R.string.hint), position + 1));
  } 
 
  @Override 
  public View onCreateView(LayoutInflater inflater,
                           ViewGroup container,
                           Bundle savedInstanceState) {
    View result=inflater.inflate(R.layout.editor, container, false);
    EditText editor=(EditText)result.findViewById(R.id.editor);
7
CodeRank
This code example shows how to use the following methods:setArguments
            CountingFragment f = new CountingFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        /** 
         * 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;
        } 
 
        /** 
6
CodeRank
This code example shows how to use the following methods:setArguments
            CountingFragment f = new CountingFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        /** 
         * 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;
        } 
 
        /** 
6
CodeRank
This code example shows how to use the following methods:setArguments
     * @return {@link MainDialogFragment} instance 
     */ 
    public static MainFragment newInstance() { 
        MainFragment fragment = new MainFragment();
        Bundle arguments = new Bundle();
        fragment.setArguments(arguments);
        return fragment;
    } 
 
    /** 
     * <blockquote> 
     * onAttach(Activity) は {@link Fragment} が、{@link Activity} と紐付いた時に呼ばれます。 
     * </blockquote> 
     * 
     * もしこの {@link Fragment} が {@link Activity} に対してコールバックする必要が有る場合には、 
     * Observer パターンにしたがって、Listener インタフェースを定義して、それを {@link Activity} に実装させます。 
     * コールバックを呼ぶときは、ここで対象の {@link Activity} への参照を保存しておいて、 
     * その参照からコールバックを呼び出します。 
     * 
     * <blockquote> 
6
CodeRank
This code example shows how to use the following methods:setArguments
            CountingFragment f = new CountingFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        /** 
         * 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;
        } 
 
        /** 
6
CodeRank
This code example shows how to use the following methods:setArguments
            CountingFragment f = new CountingFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            f.setArguments(args);
 
            return f;
        } 
 
        /** 
         * 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;
        } 
 
        /** 
6
CodeRank
This code example shows how to use the following methods:setArguments
            AdFragment af = new AdFragment();
 
            // Supply num input as an argument. 
            Bundle args = new Bundle();
            args.putInt("num", num);
            af.setArguments(args);
 
            return af;
        } 
 
        /** 
         * When creating, retrieve this instance's number from its arguments. 
         */ 
        @Override 
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            Bundle args = getArguments();
            mNum = args != null ? args.getInt("num") : 1;
        } 
 
6
CodeRank

Related Fragment setArguments Questions & Answers:

setArguments Method Overview
Supply the construction arguments for this fragment.
See Code Examples for other Android Fragment Methods: