Example usage for android.app Fragment setArguments

List of usage examples for android.app Fragment setArguments

Introduction

In this page you can find the example usage for android.app Fragment setArguments.

Prototype

public void setArguments(Bundle args) 

Source Link

Document

Supply the construction arguments for this fragment.

Usage

From source file:com.antew.redditinpictures.ui.RedditImageListFragmentFree.java

public static Fragment newInstance(String subreddit, Category category, Age age) {
    final Fragment f = new RedditImageListFragmentFree();

    final Bundle args = new Bundle();
    args.putString(Constants.Extra.EXTRA_SUBREDDIT, subreddit);
    if (category != null) {
        args.putString(Constants.Extra.EXTRA_CATEGORY, category.getName());
    }/*  w w  w.  ja v  a 2s. c o  m*/
    if (age != null) {
        args.putString(Constants.Extra.EXTRA_AGE, age.getAge());
    }
    f.setArguments(args);

    return f;
}

From source file:com.antew.redditinpictures.ui.RedditImageGridFragmentFree.java

public static Fragment newInstance(String subreddit, Category category, Age age) {
    final Fragment f = new RedditImageGridFragmentFree();

    final Bundle args = new Bundle();
    args.putString(Constants.Extra.EXTRA_SUBREDDIT, subreddit);
    if (category != null) {
        args.putString(Constants.Extra.EXTRA_CATEGORY, category.getName());
    }/*from ww w.  j av a  2 s.  com*/
    if (age != null) {
        args.putString(Constants.Extra.EXTRA_AGE, age.getAge());
    }
    f.setArguments(args);

    return f;
}

From source file:ie.clashoftheash.timetabler.ui.EventDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_event_detail);

    // Show the Up button in the action bar.
    getActionBar().setDisplayHomeAsUpEnabled(true);

    // savedInstanceState is non-null when there is fragment state
    // saved from previous configurations of this activity
    // (e.g. when rotating the screen from portrait to landscape).
    // In this case, the fragment will automatically be re-added
    // to its container so we don't need to manually add it.
    // For more information, see the Fragments API guide at:
    ///*from w  ww. ja v a  2 s  .  c  o  m*/
    // http://developer.android.com/guide/components/fragments.html
    //
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putLong(EventDetailFragment.ARG_EVENT_ID,
                getIntent().getLongExtra(EventDetailFragment.ARG_EVENT_ID, -1));
        Fragment fragment = new EventDetailFragment();
        fragment.setArguments(arguments);
        getFragmentManager().beginTransaction().add(R.id.event_detail_container, fragment).commit();
    }
}

From source file:be.blinkt.openvpn.views.ScreenSlidePagerAdapter.java

@Override
public Fragment getItem(int position) {
    try {/*  w  w  w  .  ja v  a2s. co  m*/
        Fragment fragment = mTabs.get(position).fragmentClass.newInstance();
        if (mFragmentArguments != null)
            fragment.setArguments(mFragmentArguments);
        return fragment;
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:ua.boberproduction.bbr.notes.NoteEditorFragment.java

@Override
public void showNote() {
    // put data into bundle
    Bundle bundle = new Bundle();
    bundle.putInt(getString(R.string.tag_noteId), note.getId());
    bundle.putString(getString(R.string.tag_articleid), note.getArticleId());
    bundle.putString(getString(R.string.notes_title), note.getTitle());
    bundle.putString(getString(R.string.notes_note_content), note.getText());
    // create and display fragment
    Fragment fragment = new NoteViewerFragment();
    fragment.setArguments(bundle);
    FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_left, R.animator.slide_in_left,
            R.animator.slide_out_right);
    ft.replace(R.id.main_frame, fragment, getString(R.string.tag_content_fragment)).addToBackStack("edit")
            .commit();//from   w  ww  .ja va2 s.co m
}

From source file:models.newArrivalFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_newarrival, container, false);
    getActivity().setTitle("New Arrivals!");

    //animation when enter home page
    rootView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.image_click));

    //download the URL's asynchronously (put the info in the teaInfo object)
    try {/*  w w  w.j  av  a2  s .  c o  m*/
        teaInfo = new GetTeaInfoTask().execute(new ApiConnector()).get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    //make the gridview and set its adapter
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_new_arrival);
    GridViewCustomAdapter gvAdapter = new GridViewCustomAdapter(getActivity(), teaInfo.imageURLs,
            teaInfo.teaNames);
    gridView.setAdapter(gvAdapter);

    //onclick listener for gridview
    gridView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            Bundle teaViewArgs = new Bundle();
            teaViewArgs.putString("teaName", teaInfo.teaNames.get(position));
            teaViewArgs.putString("teaImgUrl", teaInfo.imageURLs.get(position));
            teaViewArgs.putString("teaDesc", teaInfo.teaDescriptions.get(position));
            Fragment newFragment = new TeaViewFragment();
            newFragment.setArguments(teaViewArgs);

            if (newFragment != null) {
                flipCard(newFragment);
            }
        }

        private void flipCard(Fragment newFragment) {
            mShowingBack = true;
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .setCustomAnimations(R.anim.card_flip_right_in, R.anim.card_flip_right_out,
                            R.anim.card_flip_left_in, R.anim.card_flip_left_out)
                    .replace(R.id.frame_container, newFragment).addToBackStack(null).commit(); // create new fragment and allow user to go back to previous fragment          
        }

    });

    return rootView;
}

From source file:com.liferay.social.activity.MainActivity.java

public void showDetails(User user) {
    Fragment fragment = new DetailsFragment();

    Bundle arguments = new Bundle();
    arguments.putSerializable("user", user);
    fragment.setArguments(arguments);

    _replaceRightFragment(fragment, DetailsFragment.TAG);
}

From source file:com.android.navigationdrawer.MainActivity.java

private void insertFragment(Fragment fragment, Bundle args) {
    fragment.setArguments(args);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(R.id.content_frame, fragment).commit();
}

From source file:org.mariotaku.twidere.activity.support.BrowserActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR);
    super.onCreate(savedInstanceState);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }//from w w w  . j  a  va 2  s .co  m
    mUri = getIntent().getData();
    if (mUri == null) {
        Toast.makeText(this, R.string.error_occurred, Toast.LENGTH_SHORT).show();
        finish();
        return;
    }
    final FragmentTransaction ft = getFragmentManager().beginTransaction();
    final Fragment fragment = Fragment.instantiate(this, BaseWebViewFragment.class.getName());
    final Bundle bundle = new Bundle();
    bundle.putString(EXTRA_URI, mUri.toString());
    fragment.setArguments(bundle);
    ft.replace(android.R.id.content, fragment);
    ft.commit();
}

From source file:edu.scranton.fisherc5.busybusy.MainActivity.java

public void setDailyViewFragment(Bundle args) {
    Fragment dailyViewFrag = new DailyViewFragment();
    dailyViewFrag.setArguments(args);
    SimpleDateFormat format = new SimpleDateFormat("MMMM d, yyyy");
    Calendar temp = new GregorianCalendar();
    temp.setTimeInMillis(args.getLong(Keys.SELECTED_DATE_KEY));

    getActionBar().setTitle(format.format(temp.getTime()));
    mDateInActionBar = true;//from   w  w w .jav  a2 s .c o  m

    //SET TRANSACTION.  ADD TO BACK STACK
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.content_frame, dailyViewFrag, "PRE_COMPARE");
    transaction.addToBackStack("PRE_COMPARE_PUSH");
    transaction.commit();
}