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


Java Fragment.getFragmentManager方法代码示例

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


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

示例1: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标fragment的前一个fragment
 *
 * @param destFragment 目标fragment
 * @return 目标fragment的前一个fragment
 */
public static Fragment getPreFragment(@NonNull final Fragment destFragment) {
    FragmentManager fragmentManager = destFragment.getFragmentManager();
    if (fragmentManager == null) return null;
    List<Fragment> fragments = getFragments(fragmentManager);
    boolean flag = false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (flag && fragment != null) {
            return fragment;
        }
        if (fragment == destFragment) {
            flag = true;
        }
    }
    return null;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:FragmentUtils.java

示例2: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标fragment的前一个fragment
 *
 * @param destFragment 目标fragment
 * @return 目标fragment的前一个fragment
 */
public static Fragment getPreFragment(@NonNull Fragment destFragment) {
    FragmentManager fragmentManager = destFragment.getFragmentManager();
    if (fragmentManager == null) return null;
    List<Fragment> fragments = getFragments(fragmentManager);
    boolean flag = false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (flag && fragment != null) {
            return fragment;
        }
        if (fragment == destFragment) {
            flag = true;
        }
    }
    return null;
}
 
开发者ID:hoangkien0705,项目名称:Android-UtilCode,代码行数:23,代码来源:FragmentUtils.java

示例3: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标fragment的前一个fragment
 *
 * @param destFragment 目标fragment
 * @return 目标fragment的前一个fragment
 */
public static Fragment getPreFragment(@NonNull Fragment destFragment) {
    FragmentManager fragmentManager = destFragment.getFragmentManager();
    if (fragmentManager == null)
        return null;
    List<Fragment> fragments = getFragments(fragmentManager);
    boolean flag = false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (flag && fragment != null) {
            return fragment;
        }
        if (fragment == destFragment) {
            flag = true;
        }
    }
    return null;
}
 
开发者ID:yangxp108,项目名称:MVPArms_Fragment-fragment,代码行数:24,代码来源:FragmentUtils.java

示例4: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标Fragment的前一个SupportFragment
 *
 * @param fragment 目标Fragment
 */
public static ISupportFragment getPreFragment(Fragment fragment) {
    FragmentManager fragmentManager = fragment.getFragmentManager();
    if (fragmentManager == null) return null;

    List<Fragment> fragmentList = FragmentationHack.getActiveFragments(fragmentManager);
    if (fragmentList == null) return null;

    int index = fragmentList.indexOf(fragment);
    for (int i = index - 1; i >= 0; i--) {
        Fragment preFragment = fragmentList.get(i);
        if (preFragment instanceof ISupportFragment) {
            return (ISupportFragment) preFragment;
        }
    }
    return null;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:22,代码来源:SupportHelper.java

示例5: setPrimaryItem

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
    Fragment fragment = (Fragment)object;
    if (fragment != mCurrentPrimaryItem) {
        if (mCurrentPrimaryItem != null) {
            mCurrentPrimaryItem.setMenuVisibility(false);
            mCurrentPrimaryItem.setUserVisibleHint(false);
        }
        if (fragment != null) {
            fragment.setMenuVisibility(true);
            if(fragment.getFragmentManager() == null) {
                Log.v(TAG, "fragment manager == null item #"+position+": f="+object);
            }
            fragment.setUserVisibleHint(true);
        }
        mCurrentPrimaryItem = fragment;
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:19,代码来源:FragmentsAdapter.java

示例6: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * Gets the previous fragment of the target fragment
 *
 * @param destFragment Target fragment
 * @return The previous fragment of the target fragment
 */
public static Fragment getPreFragment(@NonNull Fragment destFragment) {
    FragmentManager fragmentManager = destFragment.getFragmentManager();
    if (fragmentManager == null)
        return null;
    List<Fragment> fragments = getFragments(fragmentManager);
    boolean flag = false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (flag && fragment != null) {
            return fragment;
        }
        if (fragment == destFragment) {
            flag = true;
        }
    }
    return null;
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:24,代码来源:FragmentUtils.java

示例7: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标Fragment的前一个Fragment
 *
 * @param fragment 目标Fragment
 */
SupportFragment getPreFragment(Fragment fragment) {
    FragmentManager fragmentManager = fragment.getFragmentManager();
    fragmentManager = checkFragmentManager(fragmentManager, null);
    if (fragmentManager == null) return null;

    List<Fragment> fragmentList = fragmentManager.getFragments();
    if (fragmentList == null) return null;

    int index = fragmentList.indexOf(fragment);
    for (int i = index - 1; i >= 0; i--) {
        Fragment preFragment = fragmentList.get(i);
        if (preFragment instanceof SupportFragment) {
            return (SupportFragment) preFragment;
        }
    }
    return null;
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:23,代码来源:FragmentationDelegate.java

示例8: getPreFragment

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * 获取目标fragment的前一个fragment
 *
 * @param destFragment 目标fragment
 * @return 目标fragment的前一个fragment
 */
public static Fragment getPreFragment(@NonNull Fragment destFragment) {
    FragmentManager fragmentManager = destFragment.getFragmentManager();
    if (fragmentManager == null) {
        return null;
    }
    List<Fragment> fragments = getFragments(fragmentManager);
    boolean flag = false;
    for (int i = fragments.size() - 1; i >= 0; --i) {
        Fragment fragment = fragments.get(i);
        if (flag && fragment != null) {
            return fragment;
        }
        if (fragment == destFragment) {
            flag = true;
        }
    }
    return null;
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:25,代码来源:FragmentUtils.java

示例9: isValid

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
@Override
public boolean isValid() {
	Fragment fragment = get();

	return fragment != null &&
			fragment.getHost() != null &&
			fragment.getFragmentManager() != null && !fragment.getFragmentManager().isDestroyed() &&
			fragmentSaveInstanceStateIsNotCalled(fragment);
}
 
开发者ID:tuenti,项目名称:android-deferred,代码行数:10,代码来源:FragmentContextHolder.java

示例10: AutoClearedValue

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public AutoClearedValue(Fragment fragment, T value) {
    FragmentManager fragmentManager = fragment.getFragmentManager();
    fragmentManager.registerFragmentLifecycleCallbacks(
            new FragmentManager.FragmentLifecycleCallbacks() {
                @Override
                public void onFragmentViewDestroyed(FragmentManager fm, Fragment f) {
                    if (f == fragment) {
                        AutoClearedValue.this.value = null;
                        fragmentManager.unregisterFragmentLifecycleCallbacks(this);
                    }
                }
            },false);
    this.value = value;
}
 
开发者ID:googlesamples,项目名称:android-architecture-components,代码行数:15,代码来源:AutoClearedValue.java

示例11: addCancelOnFragmentDestroyIfSet

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
void addCancelOnFragmentDestroyIfSet() {
    if (cancelOnDestroyFragment == null) {
        return;
    }
    Fragment fragment = cancelOnDestroyFragment.get();
    if (fragment == null) {
        return;
    }
    FragmentManager manager = fragment.getFragmentManager();
    if (manager != null) {
        manager.registerFragmentLifecycleCallbacks(
                new CCMonitor.FragmentMonitor(this)
                , false);
    }
}
 
开发者ID:luckybilly,项目名称:CC,代码行数:16,代码来源:CC.java

示例12: AutoClearedValue

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public AutoClearedValue(Fragment fragment, T value) {
    FragmentManager fragmentManager = fragment.getFragmentManager();
    fragmentManager.registerFragmentLifecycleCallbacks(
            new FragmentManager.FragmentLifecycleCallbacks() {
                @Override
                public void onFragmentViewDestroyed(FragmentManager fm, Fragment f) {
                    AutoClearedValue.this.value = null;
                    fragmentManager.unregisterFragmentLifecycleCallbacks(this);
                }
            },false);
    this.value = value;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:13,代码来源:AutoClearedValue.java

示例13: clearBackStack

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void clearBackStack(Fragment fragment) {
    FragmentManager fm = fragment.getFragmentManager();
    clearBackStack(fm);
}
 
开发者ID:CIS-Extra,项目名称:mazes_and_minotaurs,代码行数:5,代码来源:Util.java

示例14: show

import android.support.v4.app.Fragment; //导入方法依赖的package包/类
/**
 * Shows the dialog. Results will be forwarded to the fragment supplied.
 * The tag can be used to identify the dialog in {@link OnDialogResultListener#onResult}
 *
 * @param fragment the hosting fragment
 * @param tag the dialogs tag
 */
public void show(Fragment fragment, String tag){
    setTargetFragment(fragment, -1);
    try {
        super.show(fragment.getFragmentManager(), tag);
    } catch (IllegalStateException ignored){}
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:14,代码来源:SimpleDialog.java


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