本文整理匯總了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();
}