當前位置: 首頁>>代碼示例>>Java>>正文


Java Fragment.setArguments方法代碼示例

本文整理匯總了Java中android.support.v4.app.Fragment.setArguments方法的典型用法代碼示例。如果您正苦於以下問題:Java Fragment.setArguments方法的具體用法?Java Fragment.setArguments怎麽用?Java Fragment.setArguments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.setArguments方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addFragment

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void addFragment(final Fragment fragment) {
    final FragmentManager fragmentManager = getSupportFragmentManager();
    final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    boolean retain = isRetainPresenterInstance();
    if (retain) {
        Log.v(TAG, "retaining presenter");
    }
    if (fragment.getArguments() == null) {
        final Bundle bundle = new Bundle();
        bundle.putBoolean(TestFragment.RETAIN_PRESENTER, retain);
        fragment.setArguments(bundle);
    } else {
        Log.v(TAG, "reusing fragment, not setting new arguments");
    }

    fragmentTransaction.replace(R.id.fragment_placeholder, fragment);
    if (isAddToBackStack()) {
        Log.v(TAG, "adding transaction to the back stack");
        fragmentTransaction.addToBackStack(null);
    }
    final int backStackId = fragmentTransaction.commit();
    if (backStackId >= 0) {
        Log.v(TAG, "Back stack ID: " + String.valueOf(backStackId));
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:FragmentLifecycleActivity.java

示例2: onCreate

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list_item);
    buildingName = getIntent().getStringExtra("extra");
    getSupportActionBar().setTitle(buildingName);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    //store building name in a bundle that we will pass to fragment
    Bundle bundle=new Bundle();
    bundle.putString("name", buildingName);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();

    Fragment fragment = new RoomListFragment();
    fragment.setArguments(bundle);

    //create fragment
    ft.add(R.id.listview_fragment_container, fragment);
    ft.commit();
}
 
開發者ID:ma8642,項目名稱:FindSpot,代碼行數:21,代碼來源:RoomListActivity.java

示例3: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(Cursor c, int position) {
    final Fragment f = new PhotoViewFragment();
    final Bundle b = new Bundle();

    int photoID = c.getInt(0);
    b.putInt(MediaSetUtils.PHOTO_ID, photoID);

    String path = c.getString(1);
    b.putString(MediaSetUtils.PHOTO_PATH, path);

    String type = c.getString(2);
    b.putInt(TYPE, type == null ? MediaSetUtils.TYPE_IMAGE :
            (type.startsWith("video") ? MediaSetUtils.TYPE_VIDEO : MediaSetUtils.TYPE_IMAGE));

    b.putInt(CURRENT_POSITION, position);
    f.setArguments(b);
    return f;
}
 
開發者ID:YuntaoWei,項目名稱:PictureShow,代碼行數:19,代碼來源:PhotoViewFragment.java

示例4: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(String webViewHtml) {
    Fragment frag = new InfoFragment();
    Bundle b = new Bundle();
    b.putString(WEBVIEW_HTML, webViewHtml);
    frag.setArguments(b);
    return frag;
}
 
開發者ID:abhijitvalluri,項目名稱:fitnotifications,代碼行數:8,代碼來源:InfoFragment.java

示例5: showPrivateChatRoom

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void showPrivateChatRoom(DialogModel dialogModel) {
    String tag = CHAT_ROOM_FR_TAG + dialogModel.getDialogId();

    FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();
    Fragment fragment = getActivity().getSupportFragmentManager().findFragmentByTag(tag);
    getActivity().getSupportFragmentManager().popBackStackImmediate();

    if (fragment != null) {
        transaction.replace(R.id.main_screen_container, fragment, tag)
                .commit();
        return;
    }

    fragment = new ChatRoomFragment();
    Bundle args = new Bundle();
    args.putString(ChatRoomFragment.DIALOG_ID_BUNDLE_KEY, dialogModel.getDialogId());
    args.putLong(ChatRoomFragment.DIALOG_ADMIN_BUNDLE_KEY, dialogModel.getAdminId());
    args.putString(ChatRoomFragment.DIALOG_NAME_BUNDLE_KEY, dialogModel.getName());
    args.putInt(ChatRoomFragment.DIALOG_TYPE_BUNDLE_KEY, dialogModel.getType());
    args.putString(ChatRoomFragment.DIALOG_ROOM_JID_BUNDLE_KEY, dialogModel.getXmppRoomJid());
    ArrayList<Integer> list = new ArrayList<>(dialogModel.getOccupantsIds());
    args.putIntegerArrayList(ChatRoomFragment.OCCUPANTS_IDS_BUNDLE_KEY, list);

    fragment.setArguments(args);

    transaction.replace(R.id.main_screen_container, fragment, tag)
            .addToBackStack(PRIVATE_DIALOGS_FR_TAG)
            .commit();

}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:32,代碼來源:NewChatFragment.java

示例6: onItemClick

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> listView, View v, int position, long id) {
  Object o = liste.get(position);
  // PinnedSectionListView tillader klik på hængende overskrifter, selvom adapteren siger at det skal den ikke
  if (!(o instanceof Udsendelse)) return;
  Udsendelse u = (Udsendelse) o;
  if (position == 0 || position == liste.size() - 1) {
    hentSendeplanForDag(u.startTid);
    v.findViewById(R.id.titel).setVisibility(View.GONE);
    v.findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
  } else {
    //startActivity(new Intent(getActivity(), VisFragment_akt.class)
    //    .putExtra(P_KANALKODE, getKanal.kode)
    //    .putExtra(VisFragment_akt.KLASSE, Udsendelse_frag.class.getName()).putExtra(P_UDSENDELSE, u.slug)); // Udsenselses-ID
    String aktuelUdsendelseSlug = aktuelUdsendelseIndex > 0 ? ((Udsendelse) liste.get(aktuelUdsendelseIndex)).slug : "";

    // Vis normalt et Udsendelser_vandret_skift_frag med flere udsendelser
    // Hvis tilgængelighed er slået til (eller bladring slået fra) vises blot ét Udsendelse_frag
    Fragment f =
        App.accessibilityManager.isEnabled() || !App.prefs.getBoolean("udsendelser_bladr", true) ? Fragmentfabrikering.udsendelse(u) :
            new Udsendelser_vandret_skift_frag();
    f.setArguments(new Intent()
        .putExtra(P_KANALKODE, kanal.kode)
        .putExtra(Udsendelse_frag.AKTUEL_UDSENDELSE_SLUG, aktuelUdsendelseSlug)
        .putExtra(P_UDSENDELSE, u.slug)
        .getExtras());
    getActivity().getSupportFragmentManager().beginTransaction()
        .replace(R.id.indhold_frag, f)
        .addToBackStack(null)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
        .commitAllowingStateLoss(); // Fix for https://www.bugsense.com/dashboard/project/cd78aa05/errors/830038058
    Sidevisning.vist(Udsendelse_frag.class, u.slug);
  }
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:35,代碼來源:Kanal_frag.java

示例7: instantiate

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment instantiate(Long uid) {
    Bundle bundle = new Bundle();
    bundle.putLong(BUNDLE_KEY_USER_ID, uid);
    Fragment fragment = new UserActiveFragment();
    fragment.setArguments(bundle);
    return fragment;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:8,代碼來源:UserActiveFragment.java

示例8: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(Bundle args) {
    Fragment fragment;
    if (args.getInt(Extra.OWNER_ID) > 0) {
        fragment = new UserWallFragment();
    } else {
        fragment = new GroupWallFragment();
    }

    fragment.setArguments(args);
    return fragment;
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:12,代碼來源:AbsWallFragment.java

示例9: instantiate

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment instantiate(long uid) {
    Bundle bundle = new Bundle();
    bundle.putLong(BUNDLE_KEY_USER_ID, uid);
    Fragment fragment = new UserBlogFragment();
    fragment.setArguments(bundle);
    return fragment;
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:8,代碼來源:UserBlogFragment.java

示例10: onItemClick

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onItemClick(AdapterView<?> listView, View v, int position, long id) {
  Object o = liste.get(position);
  if (o instanceof Udsendelse) {
    Udsendelse udsendelse = (Udsendelse) o;
    // Vis normalt et Udsendelser_vandret_skift_frag med flere udsendelser
    // Hvis tilgængelighed er slået til (eller bladring slået fra) vises blot ét Udsendelse_frag
    Fragment f =
        App.accessibilityManager.isEnabled() || !App.prefs.getBoolean("udsendelser_bladr", true) ? Fragmentfabrikering.udsendelse(udsendelse) :
                new Udsendelser_vandret_skift_frag(); // standard
    f.setArguments(new Intent()
        .putExtra(Udsendelse_frag.BLOKER_VIDERE_NAVIGERING, true)
        .putExtra(P_KANALKODE, kanal == null ? null : kanal.kode)
        .putExtra(P_UDSENDELSE, udsendelse.slug)
        .getExtras());
    getActivity().getSupportFragmentManager().beginTransaction()
        .replace(R.id.indhold_frag, f)
        .addToBackStack(null)
        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
        .commitAllowingStateLoss(); // Fix for https://mint.splunk.com/dashboard/project/cd78aa05/errors/4061148411
    Sidevisning.vist(Udsendelse_frag.class, udsendelse.slug);
    return;
  }

  hentUdsendelser(programserie.getUdsendelser().size());
  v.findViewById(R.id.titel).setVisibility(View.GONE);
  v.findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:29,代碼來源:Programserie_frag.java

示例11: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(boolean animateEnter) {
    final Bundle args = new Bundle();
    args.putBoolean("animateEnter", animateEnter);
    final Fragment waterFragment = new Fragment1();
    waterFragment.setArguments(args);
    return waterFragment;
}
 
開發者ID:florent37,項目名稱:Depth,代碼行數:8,代碼來源:Fragment1.java

示例12: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(int type) {

        Bundle args = new Bundle();

        Fragment fragment;
        if (mCachedFragments.get(type) != null) {
            fragment = mCachedFragments.get(type);
        } else {
            switch (type) {
                case Constants.TYPE_DISCOVERY:
                    fragment = DiscoveryFragment_.newInstance();
                    break;
                case Constants.TYPE_ME:
                    fragment = MeFragment_.newInstance();
                    break;
                case Constants.TYPE_STAR:
                    fragment = StarFragment_.newInstance();
                    break;
                case Constants.TYPE_TRENDS:
                default:
                    fragment = TrendsFragment_.newInstance();
                    break;
            }
            mCachedFragments.put(type, fragment);
        }
        fragment.setArguments(args);
        return fragment;
    }
 
開發者ID:auv1107,項目名稱:TextEmoji,代碼行數:29,代碼來源:FragmentFactory.java

示例13: newInstance

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
public static Fragment newInstance(String detailId){
    Bundle bundle = new Bundle();
    bundle.putSerializable(EXTRA_DETAIL_ID,detailId);
    Fragment fragment = new HelpsDetailFragment();
    fragment.setArguments(bundle);
    return fragment;
}
 
開發者ID:newbiechen1024,項目名稱:NovelReader,代碼行數:8,代碼來源:HelpsDetailFragment.java

示例14: Programserie_frag

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private static void åbn(Basisfragment ths, Programserie programserie) {
  Fragment f = new Programserie_frag();
  f.setArguments(new Intent()
      .putExtra(P_PROGRAMSERIE, programserie.slug)
      .getExtras());
  ths.getActivity().getSupportFragmentManager().beginTransaction()
      .replace(R.id.indhold_frag, f)
      .addToBackStack(null)
      .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
      .commit();
  Sidevisning.vist(Programserie_frag.class, programserie.slug);
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:13,代碼來源:DramaOgBog_frag.java

示例15: setupViewPager

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void setupViewPager(ViewPager viewPager, List<XianduCategory> xianduCategories) {
    ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());

    for (XianduCategory xiandu : xianduCategories) {
        Fragment fragment = new CategoryFragment();
        Bundle data = new Bundle();
        data.putString("url", xiandu.getUrl());
        fragment.setArguments(data);
        adapter.addFrag(fragment, xiandu.getName());
    }

    viewPager.setAdapter(adapter);

}
 
開發者ID:li-yu,項目名稱:FakeWeather,代碼行數:15,代碼來源:ReadingFragment.java


注:本文中的android.support.v4.app.Fragment.setArguments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。