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.example.android.adrenaland.MainActivity.java

public void selectItemSeeRidePin(boolean cloud, boolean bigDrop) {
    Fragment fragment = new FragmentNavigation();
    Bundle args = new Bundle();
    args.putBoolean(FragmentNavigation.ARG_CLOUD, cloud);
    args.putBoolean(FragmentNavigation.ARG_BIG_DROP, bigDrop);
    fragment.setArguments(args);
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction ft = fragmentManager.beginTransaction();

    ft.replace(R.id.content_frame, fragment).commit();

    mDrawerList.setItemChecked(1, true);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:edu.nau.CS477.Classes.MainActivity.java

private void selectItem(int position) {
    Bundle args = new Bundle();

    Fragment fragment = null;
    switch (position) {
    case 0:/*from  w  ww  .j a  va2  s.c o  m*/
        fragment = new ContactsFragment();
        args.putInt(ContactsFragment.MENU_ITEM_NUMBER, position);
        fragment.setArguments(args);
        break;
    case 1:
        fragment = new ChatFragment();
        args.putInt(ChatFragment.MENU_ITEM_NUMBER, position);
        fragment.setArguments(args);
        break;
    case 2:
        fragment = new FileBrowserFragment();
        args.putInt(FileBrowserFragment.MENU_ITEM_NUMBER, position);
        fragment.setArguments(args);
        break;
    case 3:
        fragment = new FTPTransferFragment();
        args.putInt(FTPTransferFragment.MENU_ITEM_NUMBER, position);
        fragment.setArguments(args);
        break;
    case 4:
        fragment = new SettingsFragment();
        args.putInt(SettingsFragment.MENU_ITEM_NUMBER, position);
        fragment.setArguments(args);
        break;

    default:
        break;
    }

    if (fragment != null) {

        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);
        mDrawerList.setSelection(position);
        setTitle(mMenuItems[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    } else {
        // error in creating fragment
        Log.e("MainActivity", "Error in creating fragment");
    }

}

From source file:com.sopra.demo.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment;
    if (position == 0) {
        fragment = new WebViewFragment();
    } else {/*from w  ww.  j  a  v a 2 s .  c  om*/
        fragment = new MapFragment();
    }
    Bundle args = new Bundle();
    fragment.setArguments(args);

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

    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.jklinson.fisatarticles.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = null;
    Log.i("Selected Item", "Position =" + position);
    switch (position) {
    case 0://from  w  ww.ja va  2s .c  o m
        fragment = latestNewsFragment;
        Bundle args = new Bundle();
        fragment.setArguments(args);
        break;

    case 1:
        fragment = new AboutFragment();
        break;
    case 2:
        fragment = new AboutFragment();
        break;
    case 3:
        fragment = new AboutFragment();
        break;
    case 4:
        fragment = new AboutFragment();

        break;

    default:

        break;
    }
    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(titles[position]);
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:com.unicamp.br.mo409.controller.MainActivity.java

public void callNewFragment(int position, Fragment fragment) {
    // update the main content by replacing fragments
    Bundle args = new Bundle();
    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(mTitles[position]);//from   ww  w . j  ava  2  s . c  o m
    mDrawerLayout.closeDrawer(mDrawerList);
}

From source file:nl.saxion.weact.MainActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments

    String action = mPlanetTitles[position];
    Fragment fragment;
    if (action.equals("Profiel aanpassen")) {
        fragment = new ProfileAanpassen();
    } else {//  ww  w .  j av  a2  s.com
        fragment = new PlanetFragment();
        Bundle args = new Bundle();
        args.putInt(PlanetFragment.ARG_PLANET_NUMBER, position);
        fragment.setArguments(args);

        //           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);
    }
    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:de.fhb.mi.paperfly.user.FriendListFragment.java

@Override
public void onListItemClick(ListView l, View v, int position, long id) {
    Log.d(TAG, "onItemClick");
    Fragment fragment = new UserProfileFragment();
    Bundle args = new Bundle();
    args.putString(UserProfileFragment.ARGS_USER, listAdapter.getItem(position).getUsername());
    args.putBoolean(UserProfileFragment.ARGS_USER_IS_FRIEND, true);
    fragment.setArguments(args);
    // Insert the fragment by replacing any existing fragment
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.content_frame, fragment).commit();
}

From source file:com.tobbetu.en4s.navigationDrawer.ListActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new ComplaintListFragment();
    Bundle args = new Bundle();
    args.putInt(ComplaintListFragment.ARG_COMPLAINT_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(TITLES[position]);//w w w  . j  av  a2s.  com
    mDrawerLayout.closeDrawer(relativeDrawerLayout);
}

From source file:com.autoparts.buyers.activity.MainDrawerActivity.java

private void selectItem(int position) {
    // update the main content by replacing fragments
    Fragment fragment = new MainBuyerFragment();
    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);
    mDrawerLayout.closeDrawer(drawer_view);
}

From source file:com.zzolta.android.gfrecipes.activities.MainActivity.java

private Fragment setupRecipeDetailFragment(int position) {
    final Fragment fragment = new RecipeDetailFragment();
    final Bundle bundle = new Bundle();
    final String recipeOfTheDay = getRecipeOfTheDay();
    if (recipeOfTheDay != null) {
        bundle.putString(ApplicationConstants.RECIPE_OF_THE_DAY_ID, recipeOfTheDay);
    }//from w ww. j  ava 2 s.c  o  m
    bundle.putInt(ApplicationConstants.ARG_SECTION_NUMBER, position);
    fragment.setArguments(bundle);
    return fragment;
}