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


Java FragmentManager.beginTransaction方法代码示例

本文整理汇总了Java中android.support.v4.app.FragmentManager.beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.beginTransaction方法的具体用法?Java FragmentManager.beginTransaction怎么用?Java FragmentManager.beginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.FragmentManager的用法示例。


在下文中一共展示了FragmentManager.beginTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initFragment

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void initFragment(){
    homeMyFragment = HomeMyFragment.newInstance();
    homeMyFragment.setOnRefresh(new HomeMyFragment.OnRefresh() {
        @Override
        public void success() {
            pullToRefreshLayout.finishRefresh();
        }

        @Override
        public void error() {
            pullToRefreshLayout.finishRefresh();
            showToast("加载失败,请重试");
        }
    });
    FragmentManager fm = getChildFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.id.home_fragment_container, homeMyFragment);
    ft.commit();
}
 
开发者ID:ruiqiao2017,项目名称:Renrentou,代码行数:20,代码来源:HomeFragment.java

示例2: replaceFragment

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 替换碎片
 * 为了保证不出现碎片重叠现象,手动禁用控件并延迟启用
 * @param fragment
 * @param slideType
 */
private void replaceFragment(Fragment fragment, int slideType) {

    FragmentManager manager = getActivity().getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();

    switch (slideType){
        case SLIDE_FROM_LEFT_TO_RIGHT:
            transaction.setCustomAnimations(R.anim.slide_left_in,R.anim.slide_right_out);
            break;
        case SLIDE_FROM_RIGHT_TO_LEFT:
            transaction.setCustomAnimations(R.anim.slide_right_in,R.anim.slide_left_out);
            break;
    }

    transaction.replace(R.id.findpwd_main_frame, fragment);
    transaction.commit();

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {}
    }, 200);
}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:29,代码来源:FragmentVerifyPhone.java

示例3: changeView

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void changeView(int position) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    Fragment fragment = mFragments.get(position);
    if (fragment.isAdded()) {
        transaction.show(fragment);
    } else {
        transaction.add(R.id.sticky_container, fragment);
        mVisibleFragments.add(fragment);
    }
    for (Fragment fragment1 : mVisibleFragments) {
        if (fragment1 != fragment) {
            if (fragment1.isVisible()) {
                transaction.hide(fragment1);
                transaction.addToBackStack(null);
            }
        }
    }
    transaction.commit();
}
 
开发者ID:yedashen,项目名称:UltimateRecyclerView,代码行数:21,代码来源:LikeStickListViewActivity.java

示例4: showAlipayDialog

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@TargetApi(17)
private void showAlipayDialog(boolean notOpenFlag) {
    FragmentManager fm = getSupportFragmentManager();
    if (fm != null && getActivity() != null && !getActivity().isDestroyed()) {
        FragmentTransaction ft = fm.beginTransaction();
        this.mAlipayAutoPayDialog = (AlipayAutoPayDialog) fm.findFragmentByTag("showmAlipayPayDialog");
        Bundle bundle = new Bundle();
        bundle.putBoolean(AlipayConstant.NOT_OPEN_CONTINUE_MONTHLY, notOpenFlag);
        bundle.putBoolean(AlipayConstant.IS_MOBILE_VIP_FLAG, this.mIsMobileVipFlag);
        if (this.mAlipayAutoPayDialog == null) {
            this.mAlipayAutoPayDialog = new AlipayAutoPayDialog();
        } else {
            ft.remove(this.mAlipayAutoPayDialog);
        }
        this.mAlipayAutoPayDialog.setAlipayConfirmCallback(this);
        if (this.mAlipayAutoPayDialog.getArguments() == null) {
            this.mAlipayAutoPayDialog.setArguments(bundle);
        }
        ft.add(this.mAlipayAutoPayDialog, "showmAlipayPayDialog");
        ft.commitAllowingStateLoss();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:23,代码来源:VipOrderDetailActivity.java

示例5: createTransaction

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private FragmentTransaction createTransaction(@NonNull FragmentManager fragmentManager) {
    if (parameters != null && !parameters.isEmpty()) {
        fragment.setArguments(parameters);
    }

    FragmentTransaction transaction = fragmentManager.beginTransaction();

    if (addToBackStack) {
        transaction.addToBackStack(fragment.getClass().getSimpleName());
    }

    if (!sharedElement.isEmpty() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        for (View element : sharedElement) {
            transaction.addSharedElement(element, element.getTransitionName());
        }

    }

    if (animation != null) {
        transaction.setCustomAnimations(animation.getEnter(),
                                        animation.getExit(),
                                        animation.getPopEnter(),
                                        animation.getPopExit());
    }

    return transaction;
}
 
开发者ID:interactiveservices,项目名称:utils-android,代码行数:29,代码来源:FragmentBuilder.java

示例6: addFragmentToActivity

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public static void addFragmentToActivity (FragmentManager fragmentManager,
                                          Fragment fragment,
                                          int frameId,
                                          String tag) {

    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment, tag);
    transaction.commit();
}
 
开发者ID:BracketCove,项目名称:RoomDemo2017,代码行数:10,代码来源:BaseActivity.java

示例7: 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 (FragmentManager fragmentManager,
                                          Fragment fragment,
                                          int frameId,
                                          String tag) {

    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.replace(frameId, fragment, tag);
    transaction.commit();
}
 
开发者ID:BracketCove,项目名称:PosTrainer,代码行数:15,代码来源:ActivityUtils.java

示例8: 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) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ActivityUtils.java

示例9: replaceFragment

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
 * 替换碎片
 * 为了保证不出现碎片重叠现象,手动禁用控件并延迟启用
 * @param fragment
 * @param slideType
 */
private void replaceFragment(Fragment fragment, int slideType) {

    navigationView.setAllButtonEnabled(false);

    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();

    switch (slideType){
        case SLIDE_FROM_LEFT_TO_RIGHT:
            transaction.setCustomAnimations(R.anim.slide_left_in,R.anim.slide_right_out);
            break;
        case SLIDE_FROM_RIGHT_TO_LEFT:
            transaction.setCustomAnimations(R.anim.slide_right_in,R.anim.slide_left_out);
            break;
    }

    transaction.replace(R.id.main_frame, fragment);
    transaction.commit();

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            navigationView.setAllButtonEnabled(true);
        }
    }, 200);
}
 
开发者ID:838030195,项目名称:DaiGo,代码行数:33,代码来源:ClientMainActivity.java

示例10: dismissDialog

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public static void dismissDialog(FragmentManager manager) {
    FragmentTransaction ft = manager.beginTransaction();
    Fragment fragment = manager.findFragmentByTag("dialog");
    if (fragment != null) {
        ft.remove(fragment).commit();
    }
}
 
开发者ID:morogoku,项目名称:MTweaks-KernelAdiutorMOD,代码行数:8,代码来源:ViewUtils.java

示例11: addFragmentToActivityWithSharedElement

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public static void addFragmentToActivityWithSharedElement(
        @NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId, String tag,
        int enterAnimation, int exitAnimation, int popEnter, int popExit, View sharedElement,
        String transitionName) {

    checkNotNull(fragmentManager);
    checkNotNull(fragment);

    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.setCustomAnimations(enterAnimation, exitAnimation, popEnter, popExit);
    fragmentTransaction.addSharedElement(sharedElement, transitionName);
    fragmentTransaction.replace(frameId, fragment, tag);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commitAllowingStateLoss();
}
 
开发者ID:sciage,项目名称:FinalProject,代码行数:16,代码来源:ActivityUtils.java

示例12: show

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void show(FragmentManager fragmentManager, String tag) {
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    Fragment prevFragment = fragmentManager.findFragmentByTag(tag);
    if (prevFragment != null) {
        transaction.remove(prevFragment);
    }
    transaction.addToBackStack(null);
    show(transaction, tag);
}
 
开发者ID:MindorksOpenSource,项目名称:android-mvp-interactor-architecture,代码行数:10,代码来源:BaseDialog.java

示例13: changeChildrenPresence

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void changeChildrenPresence(boolean isPresented) {
    FragmentManager childFragmentManager = getChildFragmentManager();
    FragmentTransaction fragmentTransaction = childFragmentManager.beginTransaction();

    Fragment child1 = childFragmentManager.findFragmentById(R.id.childContainer1);
    Fragment child2 = childFragmentManager.findFragmentById(R.id.childContainer2);

    if (isPresented) {
        // Add children if they aren't presented
        if (child1 == null) {
            fragmentTransaction.add(R.id.childContainer1, new ChildFragment());
        }
        if (child2 == null) {
            fragmentTransaction.add(R.id.childContainer2, new ChildFragment());
        }
    } else {
        // Remove children if they are presented
        if (child1 != null) {
            fragmentTransaction.remove(child1);
        }
        if (child2 != null) {
            fragmentTransaction.remove(child2);
        }
    }

    fragmentTransaction.commit();
}
 
开发者ID:Jeevuz,项目名称:Outlast,代码行数:28,代码来源:MainFragment.java

示例14: onCreate

import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle icicle, @NonNull MasterSecret masterSecret) {
  this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

  Fragment fragment = new MmsPreferencesFragment();
  FragmentManager fragmentManager = getSupportFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.replace(android.R.id.content, fragment);
  fragmentTransaction.commit();

}
 
开发者ID:CableIM,项目名称:Cable-Android,代码行数:12,代码来源:MmsPreferencesActivity.java

示例15: 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) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
开发者ID:Captwalloper,项目名称:NUI_Project,代码行数:14,代码来源:ActivityUtils.java


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