当前位置: 首页>>代码示例>>Java>>正文


Java FragmentManager类代码示例

本文整理汇总了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();
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:17,代码来源:TransactionDelegate.java

示例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();

}
 
开发者ID:goutham-kalikrishna,项目名称:ShotsNewsApp,代码行数:24,代码来源:HomeActivity.java

示例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();
    }
}
 
开发者ID:pedromassango,项目名称:Programmers,代码行数:25,代码来源:IntentUtils.java

示例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);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:20,代码来源:RMBTMainActivity.java

示例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();
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:19,代码来源:MainMenuFragment.java

示例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);
    }
}
 
开发者ID:kymjs,项目名称:Chidori,代码行数:22,代码来源:ErrorDialogManager.java

示例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);
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:28,代码来源:FragmentUtils.java

示例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);
    }
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:19,代码来源:AppInjector.java

示例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;
}
 
开发者ID:pchmn,项目名称:RxSocialAuth,代码行数:27,代码来源:RxFacebookAuth.java

示例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();
}
 
开发者ID:collaction,项目名称:freehkkai-android,代码行数:18,代码来源:SettingsActivity.java

示例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));

}
 
开发者ID:mariabecker,项目名称:OldNews,代码行数:15,代码来源:MainPageAdapter.java

示例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();
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:12,代码来源:ActivityUtils.java

示例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;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:10,代码来源:ApplicationHelper.java

示例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;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:35,代码来源:UI.java


注:本文中的android.support.v4.app.FragmentManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。