本文整理汇总了Java中android.support.v4.app.FragmentManager类的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager类的具体用法?Java FragmentManager怎么用?Java FragmentManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FragmentManager类属于android.support.v4.app包,在下文中一共展示了FragmentManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeDebouncePop
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
private void executeDebouncePop(FragmentManager fm) {
Fragment popF = fm.findFragmentByTag(fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName());
if (popF instanceof ISupportFragment) {
ISupportFragment supportF = (ISupportFragment) popF;
if (supportF.getSupportDelegate().mIsSharedElement) {
long now = System.currentTimeMillis();
if (now < mShareElementDebounceTime) {
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
return;
}
}
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
}
fm.popBackStack();
}
示例2: btnclick
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
void btnclick(View view)
{
//Fragment fragment=null;
switch (view.getId()){
case R.id.btn_learn:
fragment=new On_going_Courses_Fragment();
break;
case R.id.btn_explore:
// getNews();
fragment=new NewsFragment();
break;
case R.id.btn_profile:
fragment=new profile_fragment();
break;
}
FragmentManager fragmentManager=getSupportFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.homeFrame_PlaceHolder,fragment);
fragmentTransaction.commit();
}
示例3: showProgressFragmentDialog
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
public static void showProgressFragmentDialog(Activity activity, boolean show) {
try {
FragmentManager fm = ((AppCompatActivity) activity).getSupportFragmentManager();
if (show && progressFragmentDialog == null) {
progressFragmentDialog = new ProgressFragmentDialog();
progressFragmentDialog.show(fm, null);
return;
}
if (show) {
progressFragmentDialog.show(fm, null);
return;
}
if (progressFragmentDialog == null) {
return;
}
progressFragmentDialog.dismiss();
}catch (Exception ex){
ex.printStackTrace();
}
}
示例4: showResultsAfterTest
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
public void showResultsAfterTest(String testUuid) {
popBackStackFull();
final RMBTResultPagerFragment fragment = new RMBTResultPagerFragment();
final Bundle args = new Bundle();
args.putString(RMBTResultPagerFragment.ARG_TEST_UUID, testUuid);
fragment.setArguments(args);
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft;
ft = fm.beginTransaction();
ft.replace(R.id.fragment_content, fragment, AppConstants.PAGE_TITLE_HISTORY_PAGER);
ft.addToBackStack(AppConstants.PAGE_TITLE_HISTORY_PAGER);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
refreshActionBar(AppConstants.PAGE_TITLE_HISTORY_PAGER);
}
示例5: openSinglePlayerOptions
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
/**
* Swaps in the Single Player Options Fragment
*/
@Override
public void openSinglePlayerOptions() {
// Swap in single player menu fragment
Fragment fragment = MainMenuSinglePlayerFragment.newInstance();
// Set transitions
fragment.setEnterTransition(mNewEnterTransition);
fragment.setExitTransition(mNewExitTransition);
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.replace(R.id.menu_frame, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
示例6: onEventMainThread
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
public void onEventMainThread(ThrowableFailureEvent event) {
if (!isInExecutionScope(executionScope, event)) {
return;
}
checkLogException(event);
// Execute pending commits before finding to avoid multiple error fragments being shown
FragmentManager fm = getFragmentManager();
fm.executePendingTransactions();
DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG);
if (existingFragment != null) {
// Just show the latest error
existingFragment.dismiss();
}
DialogFragment errorFragment = (DialogFragment) factory
.prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog);
if (errorFragment != null) {
errorFragment.show(fm, TAG_ERROR_DIALOG);
}
}
示例7: addFragments
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
/**
* 新增多个fragment
*
* @param fragmentManager fragment管理器
* @param fragments fragments
* @param containerId 布局Id
* @param showIndex 要显示的fragment索引
* @param lists 共享元素链表
* @return 要显示的fragment
*/
public static Fragment addFragments(@NonNull FragmentManager fragmentManager,
@NonNull List<Fragment> fragments,
@IdRes int containerId,
int showIndex,
@NonNull List<SharedElement>... lists) {
for (int i = 0, size = fragments.size(); i < size; ++i) {
Fragment fragment = fragments.get(i);
List<SharedElement> list = lists[i];
if (fragment != null) {
if (list != null) {
putArgs(fragment, new Args(containerId, showIndex != i, false));
return operateFragment(fragmentManager, null, fragment, TYPE_ADD_FRAGMENT, list.toArray(new SharedElement[0]));
}
}
}
return fragments.get(showIndex);
}
示例8: handleActivity
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
private static void handleActivity(Activity activity) {
if (activity instanceof HasSupportFragmentInjector || activity instanceof Injectable) {
AndroidInjection.inject(activity);
}
if (activity instanceof FragmentActivity) {
((FragmentActivity) activity).getSupportFragmentManager()
.registerFragmentLifecycleCallbacks(
new FragmentManager.FragmentLifecycleCallbacks() {
@Override
public void onFragmentCreated(FragmentManager fm, Fragment f,
Bundle savedInstanceState) {
if (f instanceof Injectable) {
AndroidSupportInjection.inject(f);
}
}
}, true);
}
}
示例9: getRxFacebookAuthFragment
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
/**
* Get instance of RxFacebookAuthFragment
*
* @return a RxFacebookAuthFragment
*/
private RxFacebookAuthFragment getRxFacebookAuthFragment(Builder builder) {
FragmentManager fragmentManager = mActivity.getSupportFragmentManager();
// prevent fragment manager already executing transaction
int stackCount = fragmentManager.getBackStackEntryCount();
if( fragmentManager.getFragments() != null )
fragmentManager = fragmentManager.getFragments().get( stackCount > 0 ? stackCount-1 : stackCount ).getChildFragmentManager();
RxFacebookAuthFragment rxFacebookAuthFragment = (RxFacebookAuthFragment)
fragmentManager.findFragmentByTag(RxFacebookAuthFragment.TAG);
if (rxFacebookAuthFragment == null) {
rxFacebookAuthFragment = RxFacebookAuthFragment.newInstance(builder);
fragmentManager
.beginTransaction()
.add(rxFacebookAuthFragment, RxFacebookAuthFragment.TAG)
.commit();
fragmentManager.executePendingTransactions();
}
return rxFacebookAuthFragment;
}
示例10: onCreate
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
C.detectLanguage(mContext);
setContentView(R.layout.activity_container_adview);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
initActionBar(getSupportActionBar(), R.string.title_activity_settings);
Fragment fragment = SettingsFragment.newInstance();
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.container, fragment)
.commit();
}
示例11: openDialog
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
@Override
public void openDialog() {
if (mAndroidMediaRouter == null) {
mDelegate.onDialogCancelled();
return;
}
FragmentActivity currentActivity =
(FragmentActivity) ApplicationStatus.getLastTrackedFocusedActivity();
if (currentActivity == null) {
mDelegate.onDialogCancelled();
return;
}
FragmentManager fm = currentActivity.getSupportFragmentManager();
if (fm == null) {
mDelegate.onDialogCancelled();
return;
}
mDialogFragment = openDialogInternal(fm);
if (mDialogFragment == null) {
mDelegate.onDialogCancelled();
return;
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:BaseMediaRouteDialogManager.java
示例12: MainPageAdapter
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
public MainPageAdapter(FragmentManager fragmentManager, Context context){
super(fragmentManager);
mFragmentArrayList = new ArrayList<Fragment>();
mFragmentArrayList.add(new FeedFragment());
mFragmentArrayList.add(new FavouriteFeedFragment());
//mFragmentArrayList.add(new FeedFragment());
mTitleList = new ArrayList<String>();
mTitleList.add(context.getResources().getString(R.string.feed_tab));
mTitleList.add(context.getResources().getString(R.string.favorites_tab));
//mTitleList.add(context.getResources().getString(R.string.ocr_tab));
}
示例13: addFragmentToActivity
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
/**
* The {@code fragment} is added to the container view with id {@code frameId}. The operation is
* performed by the {@code fragmentManager}.
*
*/
public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
@NonNull Fragment fragment, int frameId) {
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(frameId, fragment);
transaction.commit();
}
示例14: setup
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
@Nullable
public static ApplicationPagerAdapter setup(AutoScrollViewPager viewPager, FragmentManager fragmentManager, Context context) {
if (viewPager == null) return null;
DLog.d(TAG, "setup() called");
ApplicationPagerAdapter adapter = new ApplicationPagerAdapter(fragmentManager, context);
viewPager.setAdapter(adapter);
viewPager.startAutoScroll();
return adapter;
}
示例15: addFragments
import android.support.v4.app.FragmentManager; //导入依赖的package包/类
public List<TFragment> addFragments(List<TFragment> fragments) {
List<TFragment> fragments2 = new ArrayList<TFragment>(fragments.size());
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
boolean commit = false;
for (int i = 0; i < fragments.size(); i++) {
// install
TFragment fragment = fragments.get(i);
int id = fragment.getContainerId();
// exists
TFragment fragment2 = (TFragment) fm.findFragmentById(id);
if (fragment2 == null) {
fragment2 = fragment;
transaction.add(id, fragment);
commit = true;
}
fragments2.add(i, fragment2);
}
if (commit) {
try {
transaction.commitAllowingStateLoss();
} catch (Exception e) {
}
}
return fragments2;
}