本文整理汇总了Java中android.support.v4.app.FragmentActivity.getSupportFragmentManager方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentActivity.getSupportFragmentManager方法的具体用法?Java FragmentActivity.getSupportFragmentManager怎么用?Java FragmentActivity.getSupportFragmentManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentActivity
的用法示例。
在下文中一共展示了FragmentActivity.getSupportFragmentManager方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: replaceFragment
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void replaceFragment(FragmentActivity context, Fragment fragment, boolean doAnimate) {
String TAG = fragment.getClass().toString();
String backStackName = fragment.getClass().getName();
FragmentManager manager = context.getSupportFragmentManager();
boolean fragmentPopped = manager.popBackStackImmediate(backStackName, 0);
if (!fragmentPopped && context.getSupportFragmentManager().findFragmentByTag(TAG) == null) {
final android.support.v4.app.FragmentTransaction ft = context.getSupportFragmentManager().beginTransaction();
if(doAnimate)
ft.setCustomAnimations(R.anim.enter,R.anim.exit,R.anim.left_to_right,R.anim.right_to_left);
else
ft.setCustomAnimations(android.R.anim.fade_in,android.R.anim.fade_out);
ft.replace(R.id.mainfragment, fragment, TAG);
ft.addToBackStack(backStackName);
ft.commit();
}
}
示例2: holderFragmentFor
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
HolderFragment holderFragmentFor(FragmentActivity activity) {
FragmentManager fm = activity.getSupportFragmentManager();
HolderFragment holder = findHolderFragment(fm);
if (holder != null) {
return holder;
}
holder = mNotCommittedActivityHolders.get(activity);
if (holder != null) {
return holder;
}
if (!mActivityCallbacksIsAdded) {
mActivityCallbacksIsAdded = true;
activity.getApplication().registerActivityLifecycleCallbacks(mActivityCallbacks);
}
holder = createHolderFragment(fm);
mNotCommittedActivityHolders.put(activity, holder);
return holder;
}
示例3: TabListener
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
* Constructor used each time a new tab is created.
*
* @param activity The host Activity, used to instantiate the fragment
* @param tag The identifier tag for the fragment
* @param clz The fragment's Class, used to instantiate the fragment
*/
public TabListener(Activity activity, String tag, Class<T> clz) {
/*
if (activity instanceof OverviewActivity) {
mActivity = (OverviewActivity) activity;
} else {
mActivity = (AboutProgramActivity) activity;
}
*/
mActivity = (FragmentActivity) activity;
mTag = tag;
mClass = clz;
FragmentManager fragmentManager = mActivity
.getSupportFragmentManager();
mFragment = fragmentManager.findFragmentByTag(mTag);
}
示例4: changeFragment
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void changeFragment(FragmentActivity activity, Fragment nextFragment, boolean addToBackStack) {
String name = nextFragment.getClass().getSimpleName();
final FragmentManager fragmentManager = activity.getSupportFragmentManager();
final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.setCustomAnimations(R.anim.slide_left_in, R.anim.slide_right_in, R.anim.slide_left_out, R.anim.slide_right_out);
fragmentTransaction.replace(R.id.frame_content, nextFragment);
if (addToBackStack) {
fragmentTransaction.addToBackStack(name);
}
try {
fragmentTransaction.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
} catch (IllegalStateException e) {
}
}
示例5: initPageView
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
private void initPageView(){
FragmentActivity activity = getActivity();
if(activity == null){
return;
}
if (adapter == null) {
adapter = new XFragmentAdapter(activity.getSupportFragmentManager(), fragmentList, titles);
}
viewPager.setOffscreenPageLimit(3);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
}
示例6: initData
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
@Override
public void initData(Bundle savedInstanceState) {
FragmentActivity activity = getActivity();
if(activity == null){
return;
}
for (int i = 0;i < 3;i++){
Fragment fragment = new AccountDetailFragment();
((AccountDetailFragment)fragment).setType(i);
fragmentList.add(fragment);
}
if (adapter == null) {
adapter = new XFragmentAdapter(activity.getSupportFragmentManager(), fragmentList, titles);
}
viewPager.setOffscreenPageLimit(1);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
tabLayout.setTabMode(TabLayout.MODE_FIXED);
}
示例7: startLogin
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/***
* 跳转到登录
* requestCode=1111
*/
public static void startLogin(FragmentActivity context, ActivityResultListner listener) {
//先看activity是否添加过该fragment, 添加根据Tag找出 ,没有就添加
FragmentManager manager = context.getSupportFragmentManager();
MyFragment myFragment = null;
Fragment loginf = manager.findFragmentByTag(MyFragment.LOGIN + "");
if (loginf == null) {
myFragment = new MyFragment();
manager.beginTransaction().add(myFragment, MyFragment.LOGIN + "").commit();
//这句是让commit立即生效,不然运行会报错,fragment还没有被attach
manager.executePendingTransactions();
} else {
myFragment = (MyFragment) loginf;
}
//设置监听
myFragment.setListener(listener);
Intent intent = new Intent(context, loginActivity.class);
myFragment.startActivityForResult(intent, MyFragment.LOGIN);
}
示例8: skjulMenu
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public void vælgMenu(FragmentActivity akt, int position) {
//new Exception().printStackTrace();
MenuElement e = elem.get(position);
skjulMenu();
if (e.runnable != null) {
e.runnable.run();
sætListemarkering(-1); // Ingen listemarkering
return;
}
sætListemarkering(position);
try {
FragmentManager fm = akt.getSupportFragmentManager();
// Fjern backstak - så vi starter forfra i 'roden'
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
Log.d("Venstremenu viser " + e.fragKlasse);
Basisfragment f = e.fragKlasse.newInstance();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.indhold_frag, f);
ft.addToBackStack("Venstremenu");
ft.commit();
Sidevisning.vist(f.getClass());
} catch (Exception e1) {
Log.rapporterFejl(e1);
}
}
示例9: TabsAdapter
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public TabsAdapter(FragmentActivity activity, ActionBar actionBar, ViewPager pager) {
super(activity.getSupportFragmentManager());
mContext = activity;
mActionBar = actionBar;
mViewPager = pager;
mViewPager.setAdapter(this);
mViewPager.setOnPageChangeListener(this);
}
示例10: setTabData
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/** 关联数据支持同时切换fragments */
public void setTabData(String[] titles, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
setTabData(titles);
}
示例11: setTabData
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/** 关联数据支持同时切换fragments */
public void setTabData(ArrayList<CustomTabEntity> tabEntitys, FragmentActivity fa, int containerViewId, ArrayList<Fragment> fragments) {
mFragmentChangeManager = new FragmentChangeManager(fa.getSupportFragmentManager(), containerViewId, fragments);
setTabData(tabEntitys);
}
示例12: MyViewPagerAdapter
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public MyViewPagerAdapter(FragmentActivity activity) {
super(activity.getSupportFragmentManager());
mContext = activity;
}
示例13: callEditDialog
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
public static void callEditDialog(FragmentActivity activity, Fragment fragment, int id, String description, int color) {
FragmentManager fm = activity.getSupportFragmentManager();
ItemPickerDialogFragment pickTaskName = ItemPickerDialogFragment.newInstance(id, description, color);
pickTaskName.setTargetFragment(fragment, EDIT_ITEM);
pickTaskName.show(fm, "edit_item");
}
示例14: getMyFragmentManager
import android.support.v4.app.FragmentActivity; //导入方法依赖的package包/类
/**
* get the support fragment manager
*
* @return FragmentManager
*/
protected FragmentManager getMyFragmentManager(FragmentActivity activity) {
return activity.getSupportFragmentManager();
}