本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
示例13: clearBackStack
import android.support.v4.app.Fragment; //导入方法依赖的package包/类
public static void clearBackStack(Fragment fragment) {
FragmentManager fm = fragment.getFragmentManager();
clearBackStack(fm);
}
示例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){}
}