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