本文整理匯總了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){}
}