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.arquitetaweb.observatorio.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new PlanetFragment();
    Bundle args = new Bundle();
    args.putInt(PlanetFragment.ARG_TYPE_GRAPH, position);
    fragment.setArguments(args);

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // update selected item and title, then close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(mPlanetTitles[position]);//from w  ww  .j  av a  2 s. co  m
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.example.android.navigationdrawerexample.activities.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new PlanetFragment();
    Bundle args = new Bundle();
    args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
    fragment.setArguments(args);

    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // update selected item and title, then close the drawer
    drawerList.setItemChecked(position, true);
    setTitle(drawerTitles[position]);//from   w  w  w . j  a  v  a  2 s .  c  o  m
    drawerLayout.closeDrawer(drawerList);
}

From source file:com.kogitune.activitytransition.fragment.FragmentTransitionLauncher.java

public void prepare(android.support.v4.app.Fragment toFragment) {
    final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap);
    if (Build.VERSION.SDK_INT >= 21) {
        toFragment.setSharedElementEnterTransition(new ChangeBounds());
        toFragment.setSharedElementReturnTransition(new ChangeBounds());
    }// ww  w.  j a  v a2  s  .c om
    toFragment.setArguments(transitionBundle);
}

From source file:com.theoreticsinc.schoolapp.activities.DrawerActivity.java

private void selectItem(int position) {

    FragmentManager fragmentManager = getFragmentManager();

    if (position == 1) {
        /*            Fragment settingsFrag = new SettingsFragment();
                    Bundle args = new Bundle();
                    args.putInt("SettingsItem", position);
                    settingsFrag.setArguments(args);
                    fragmentManager.beginTransaction().replace(R.id.content_frame, settingsFrag).commit();
        *///w ww .  j a  v  a  2s .  c  om
    } else if (position == 3) {
        Fragment newpost = new WebsiteFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        newpost.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.content_frame, newpost).commit();

    } else {
        Fragment dashFrag = new DashboardFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        dashFrag.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.content_frame, dashFrag).commit();
    }
    // update selected item and title, then close the drawer
    setTitle(settingsName[position]);
    //position = position + 1;
    mDrawerList.setItemChecked(position, true);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:ui.statisticsDisplay.activity.MainActivity.java

@Override
public void handleResultOfWebService(String methodName, Object result) {
    // TODO Auto-generated method stub
    sportData = (String) result;/*from  w  w  w.  ja v a2  s .  c  om*/
    Fragment fragment = new StartrunningActivity();
    FragmentManager fragmentManager = getFragmentManager();
    Bundle bundle = new Bundle();
    bundle.putString("sportData", sportData);
    fragment.setArguments(bundle);
    dialog.dismiss();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

}

From source file:com.kogitune.activity_transition.fragment.FragmentTransitionLauncher.java

/**
 * You should call this method after init your argumentsBundle.otherwise the transitionBundle will be not work.
 *///from   ww w  . j a  v  a 2s  .c o m
public void prepare(android.support.v4.app.Fragment toFragment) {
    final Bundle transitionBundle = TransitionBundleFactory.createTransitionBundle(context, fromView, bitmap);
    Bundle arguments = toFragment.getArguments();
    if (arguments == null) {
        arguments = new Bundle();
    }
    arguments.putBundle(TRANSITION_BUNDLE, transitionBundle);
    toFragment.setArguments(arguments);
}

From source file:me.isassist.isa.MainActivity.java

public void showLoadingFragment(String text) {
    //show the main fragment with instruction picture
    Bundle args = new Bundle();
    args.putString("LOADING_TEXT", text);
    Fragment loadingFragment = new LoadingFragment();
    loadingFragment.setArguments(args);
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.fragment_container, loadingFragment).commit();

}

From source file:com.sharklee.navigationDrawer.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new PlanetFragment();
    Bundle args = new Bundle();
    args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
    //??PlanetFragment?
    fragment.setArguments(args);
    //PlanetFragment?FrameLayout??
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.content_frame, fragment);
    fragmentTransaction.addToBackStack("");
    fragmentTransaction.commit();//from w ww. j  a v a2  s  . co m

    // update selected item and title, then close the drawer
    //MainActivityposition=0?ListView?ListView?ListView?position=0
    mDrawerList.setItemChecked(position, true);
    setTitle(mPlanetTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.jackie.navigationDrawer.MainActivity.java

/**
 * Swaps fragments in the main content view
 * @param position list position/*ww  w .j a v  a 2  s  .co  m*/
 */
private void selectItem(int position) {
    // Create a new fragment and specify the planet to show based on position
    Fragment fragment = new PlaneFragment();
    Bundle args = new Bundle();
    args.putInt(PlaneFragment.ARG_PLANET_NUMBER, position);
    fragment.setArguments(args);

    // Insert the fragment by replacing any existing existing fragment
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();

    // Highlight the selected item update the title, and close the drawer
    mDrawerList.setItemChecked(position, true);
    setTitle(mPlanetTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.theoreticsinc.brucat.activities.DrawerActivity.java

private void selectItem(int position) {

    FragmentManager fragmentManager = getFragmentManager();

    if (position == 1) {
        /*            Fragment settingsFrag = new SettingsFragment();
                    Bundle args = new Bundle();
                    args.putInt("SettingsItem", position);
                    settingsFrag.setArguments(args);
                    fragmentManager.beginTransaction().replace(R.id.content_frame, settingsFrag).commit();
        *///from w w w.ja  v  a2  s .c  o m
    } else if (position == 3) {
        Fragment newpost = new WebsiteFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        newpost.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.content_frame, newpost).addToBackStack(null).commit();

    } else {
        Fragment dashFrag = new DashboardFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        dashFrag.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.content_frame, dashFrag)
                //.addToBackStack(null)
                .commit();
    }

    // update selected item and title, then close the drawer
    setTitle(settingsName[position]);
    //position = position + 1;
    mDrawerList.setItemChecked(position, true);
    mDrawerLayout.closeDrawer(mDrawerList);
}