當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。