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.zftlive.android.sample.fadingactionbar.NavigationDrawerActivity.java

@SuppressLint("NewApi")
private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new SampleFragment();
    Bundle args = new Bundle();
    args.putInt(SampleFragment.ARG_IMAGE_RES, mCityImages[position]);
    args.putInt(SampleFragment.ARG_ACTION_BG_RES, R.drawable.ab_background);
    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(mCityNames[position]);/* w  ww .j av a 2 s .c  o m*/
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:org.qtproject.android.gallery.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new ControlFragment();
    Bundle args = new Bundle();
    args.putInt(ControlFragment.ARG_PAGE_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
    mDrawerList.setItemChecked(position, true);
    setTitle(mPageTitles[position]);/* w  w w.  jav  a2  s  . c om*/
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.socprox.prealpha.LobbyActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new NavigationFragment();
    Bundle args = new Bundle();
    args.putInt(NavigationFragment.ARG_NAVIGATION_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
    mDrawerList.setItemChecked(position, true);
    setTitle(mNavigationTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.example.tobias.androidtestapp.navigationdrawer.NavigationDrawerMain.java

private void selectItem(int position) {
    // update the main content by replacing fragments (PlanetFragment = innere Klasse)
    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
    mDrawerList.setItemChecked(position, true);
    setTitle(mPlanetTitles[position]);/*from   w  w  w. ja  v a  2s . co  m*/
    mDrawerLayout.closeDrawer(mDrawerList);
}

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

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

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  w ww  . ja  v  a 2  s.  com
public void prepare(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:com.app.avanstart.DashBoardActivity.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
    mDrawerList.setItemChecked(position, true);
    setTitle(mDrawerTitles[position]);// w w  w.  j  a v  a 2s .c  o  m
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.global.fragment.NativeMenuFragment.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new CheckSimFragment();
    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
    mDrawerList.setItemChecked(position, true);
    // setTitle(mPlanetTitles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

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

public void addFragment() {
    Fragment fragment = new StartrunningActivity();
    FragmentManager fragmentManager = getFragmentManager();
    Bundle bundle = new Bundle();
    bundle.putString("oneSport", null);
    fragment.setArguments(bundle);
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}

From source file:com.zedpine.leaguechat.MainActivity.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();
    } else if (position == 4) {
        Fragment newpost = new AddNewPostFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        newpost.setArguments(args);//from  w  w  w. jav a 2s  . c  om
        fragmentManager.beginTransaction().replace(R.id.content_frame, newpost).commit();
    } else {
        Fragment settingsFrag = new SettingsFragment();
        Bundle args = new Bundle();
        args.putInt("SettingsItem", position);
        settingsFrag.setArguments(args);
        fragmentManager.beginTransaction().replace(R.id.content_frame, settingsFrag).commit();
    }
    // update selected item and title, then close the drawer
    setTitle(settingsName[position]);
    position = position + 1;
    mDrawerList.setItemChecked(position, true);
    mDrawerLayout.closeDrawer(mDrawerList);
}