本文整理汇总了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));
}
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}