當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentTransaction.hide方法代碼示例

本文整理匯總了Java中android.support.v4.app.FragmentTransaction.hide方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentTransaction.hide方法的具體用法?Java FragmentTransaction.hide怎麽用?Java FragmentTransaction.hide使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.FragmentTransaction的用法示例。


在下文中一共展示了FragmentTransaction.hide方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showMediaGridFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void showMediaGridFragment() {
    mMediaPreviewFragment = null;
    mMediaPageFragment = null;
    mSelectedIndex = 0;

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction()
            .replace(R.id.fragment_container, mMediaGridFragment);
    if (mMediaPreviewFragment != null) {
        ft.hide(mMediaPreviewFragment);
    }
    if (mMediaPageFragment != null) {
        ft.hide(mMediaPageFragment);
    }
    ft.show(mMediaGridFragment)
            .commit();

    if (mConfiguration.isImage()) {
        mTvToolbarTitle.setText(R.string.gallery_media_grid_image_title);
    } else {
        mTvToolbarTitle.setText(R.string.gallery_media_grid_video_title);
    }
}
 
開發者ID:Loofer,項目名稱:Watermark,代碼行數:24,代碼來源:MediaActivity.java

示例2: showHideFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
void showHideFragment(FragmentManager fragmentManager, ISupportFragment showFragment, ISupportFragment hideFragment) {
    fragmentManager = checkFragmentManager(fragmentManager, null);
    if (fragmentManager == null) return;

    if (showFragment == hideFragment) return;

    FragmentTransaction ft = fragmentManager.beginTransaction().show((Fragment) showFragment);

    if (hideFragment == null) {
        List<Fragment> fragmentList = FragmentationHack.getActiveFragments(fragmentManager);
        if (fragmentList != null) {
            for (Fragment fragment : fragmentList) {
                if (fragment != null && fragment != showFragment) {
                    ft.hide(fragment);
                }
            }
        }
    } else {
        ft.hide((Fragment) hideFragment);
    }
    supportCommit(fragmentManager, ft);
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:23,代碼來源:TransactionDelegate.java

示例3: showFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void showFragment(BaseFragment fragment) {
    if (!isFinishing()) {
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        for (BaseFragment f : mFragments) {
            if (!f.isAdded()) {
                fragmentTransaction.add(R.id.fl_main, f);
            }
            if (!f.isHidden()) {
                fragmentTransaction.hide(f);
            }
        }
        fragmentTransaction.show(fragment)
                .commit();
    }
}
 
開發者ID:gaelthas,項目名稱:Palatta,代碼行數:17,代碼來源:MainActivity.java

示例4: switchFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void switchFragment(Fragment fromFragment, BaseFragment nextFragment) {

        if (mContext != nextFragment) {

            mContext = nextFragment;

            if (nextFragment != null) {
                FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

                //判斷nextFragment是否添加
                if (!nextFragment.isAdded()) {
                    //隱藏當前Fragment
                    if (fromFragment != null) {
                        transaction.hide(fromFragment);
                    }
                    transaction.add(R.id.frameLayout, nextFragment).commit();
                } else {
                    //隱藏當前Fragment
                    if (fromFragment != null) {
                        transaction.hide(fromFragment);
                    }
                    transaction.show(nextFragment).commit();
                }
            }
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:27,代碼來源:MainActivity.java

示例5: showHideFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
public static void showHideFragment(FragmentManager manager, Fragment show, Fragment hide, boolean animation, boolean backStack) {
    FragmentTransaction transaction = manager.beginTransaction();
    if (animation) {
        transaction.setCustomAnimations(
                R.anim.fragment_translate_in, R.anim.fragment_translate_out
        ,R.anim.fragment_pop_in,R.anim.fragment_pop_out);
    }
    transaction.show(show);
    if (hide == null) {
        List<Fragment> fragments = manager.getFragments();
        if (fragments != null) {
            for (Fragment fragment : fragments) {
                if (fragment != show) {
                    transaction.hide(fragment);
                }
            }
        }
    } else {
        transaction.hide(hide);
    }
    if (backStack) {
        transaction.addToBackStack("showHideFragment");
    }
    transaction.commit();
}
 
開發者ID:bigjelly,項目名稱:AndFast,代碼行數:26,代碼來源:FragmentUtils.java

示例6: handleFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void handleFragment(BaseFragment baseFragment, boolean isChecked) {
    FragmentTransaction fragmentTransaction = context.getSupportFragmentManager().beginTransaction();
    if (isChecked) {
        fragmentTransaction.show(baseFragment);
    } else {
        fragmentTransaction.hide(baseFragment);
    }
    fragmentTransaction.commit();
}
 
開發者ID:NaOHAndroid,項目名稱:Logistics-guard,代碼行數:10,代碼來源:TabView.java

示例7: switchFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void switchFragment(BaseFragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    for (BaseFragment item : this.mFragments) {
        if (item == fragment) {
            if (!fragment.isAdded()) {
                transaction.add((int) R.id.frame_content, (Fragment) fragment);
                fragment.loadFirst();
            }
            transaction.show(fragment);
        } else if (item.isAdded()) {
            transaction.hide(item);
        }
    }
    transaction.commitAllowingStateLoss();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:16,代碼來源:MainActivity.java

示例8: displayTextFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
protected void displayTextFragment() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    if (mTextFragment.isAdded()) { // if the fragment is already in container
        ft.show(mTextFragment);
    } else { // fragment needs to be added to frame container
        ft.add(R.id.content, mTextFragment, "TextFragment");
    }
    if (mBarGraphFragment.isAdded()) { ft.hide(mBarGraphFragment); }
    if (mChartFragment.isAdded()) { ft.hide(mChartFragment); }
    ft.commit();
}
 
開發者ID:hamatani63,項目名稱:Waffle,代碼行數:12,代碼來源:MainActivity.java

示例9: hide

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void hide(int position, FragmentTransaction transaction) {
    String tag = mAdapter.getTag(position);
    Fragment fragment = mFragmentManager.findFragmentByTag(tag);
    if (fragment != null) {
        transaction.hide(fragment);
    }
}
 
開發者ID:Sherchen,項目名稱:AnimationsDemo,代碼行數:8,代碼來源:FragmentNavigator.java

示例10: switchTab

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private void switchTab(int index) {
    if (index != mIndex) {
        FragmentTransaction trx = getActivity().getSupportFragmentManager()
                .beginTransaction();
        trx.hide(mFragments[mIndex]);
        if (!mFragments[index].isAdded()) {
            trx.add(mLayout.getContentId(), mFragments[index]);
        }
        trx.show(mFragments[index]).commit();
    }

    mIndex = index;
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:14,代碼來源:AddressFragment.java

示例11: startFragment

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * Show a fragment.
 *
 * @param thisFragment Now show fragment, can be null.
 * @param thatFragment fragment to display.
 * @param stickyStack  sticky back stack.
 * @param requestCode  requestCode.
 * @param <T>          {@link NoFragment}.
 */
protected final <T extends NoFragment> void startFragment(T thisFragment, T thatFragment,
                                                          boolean stickyStack, int requestCode) {
    FragmentTransaction fragmentTransaction = mFManager.beginTransaction();
    if (thisFragment != null) {
        FragmentStackEntity thisStackEntity = mFragmentEntityMap.get(thisFragment);
        if (thisStackEntity != null) {
            if (thisStackEntity.isSticky) {
                thisFragment.onPause();
                thisFragment.onStop();
                fragmentTransaction.hide(thisFragment);
            } else {
                fragmentTransaction.remove(thisFragment).commit();
                fragmentTransaction.commitNow();
                fragmentTransaction = mFManager.beginTransaction();

                mFragmentEntityMap.remove(thisFragment);
                mFragmentStack.remove(thisFragment);
            }
        }
    }

    String fragmentTag = thatFragment.getClass().getSimpleName() + mAtomicInteger.incrementAndGet();
    fragmentTransaction.add(fragmentLayoutId(), thatFragment, fragmentTag);
    fragmentTransaction.addToBackStack(fragmentTag);
    fragmentTransaction.commit();

    FragmentStackEntity fragmentStackEntity = new FragmentStackEntity();
    fragmentStackEntity.isSticky = stickyStack;
    fragmentStackEntity.requestCode = requestCode;
    thatFragment.setStackEntity(fragmentStackEntity);
    mFragmentEntityMap.put(thatFragment, fragmentStackEntity);

    mFragmentStack.add(thatFragment);
}
 
開發者ID:yanzhenjie,項目名稱:NoFragment,代碼行數:44,代碼來源:CompatActivity.java

示例12: setFragments

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/** 界麵切換控製 */
public void setFragments(int index) {
    for (int i = 0; i < mFragments.size(); i++) {
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        Fragment fragment = mFragments.get(i);
        if (i == index) {
            ft.show(fragment);
        } else {
            ft.hide(fragment);
        }
        ft.commit();
    }
    mCurrentTab = index;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:FragmentChangeManager.java

示例13: onCreate

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (savedInstanceState != null) {
        boolean isSupportHidden = savedInstanceState.getBoolean(STATE_SAVE_IS_HIDDEN);
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        if (isSupportHidden) {
            ft.hide(this);
        } else {
            ft.show(this);
        }
        ft.commit();
    }
    Log.d(TAG, "onCreate: ");
}
 
開發者ID:pan2yong22,項目名稱:AndroidUtilCode-master,代碼行數:16,代碼來源:BaseFragment.java

示例14: hideFragments

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
/**
 * 當fragment已經被實例化,就隱藏起來
 *
 * @param ft
 */
private void hideFragments(FragmentTransaction ft) {
    if (null != mNewsHomeFragment)
        ft.hide(mNewsHomeFragment);
    if (null != mVideoHomeFragment)
        ft.hide(mVideoHomeFragment);
    if (null != mWeatherFragment)
        ft.hide(mWeatherFragment);
    if (null != mCenterFragment)
        ft.hide(mCenterFragment);
}
 
開發者ID:xiarunhao123,項目名稱:PureNews,代碼行數:16,代碼來源:MainUI.java

示例15: doTabChanged

import android.support.v4.app.FragmentTransaction; //導入方法依賴的package包/類
private FragmentTransaction doTabChanged(String tabId,
                                             FragmentTransaction ft) {
        TabInfo newTab = null;
        for (int i = 0; i < mTabs.size(); i++) {
            TabInfo tab = mTabs.get(i);
            if (tab.tag.equals(tabId)) {
                newTab = tab;
            }
        }
        if (newTab == null) {
            throw new IllegalStateException("No tab known for tag " + tabId);
        }
        if (mLastTab != newTab) {
            if (ft == null) {
                ft = mFragmentManager.beginTransaction();
            }
            if (mLastTab != null) {
                if (mLastTab.fragment != null) {
//					ft.detach(mLastTab.fragment);
                    ft.hide(mLastTab.fragment);
                }
            }
            if (newTab != null) {
                if (newTab.fragment == null) {
                    newTab.fragment = Fragment.instantiate(mContext,
                            newTab.clss.getName(), newTab.args);
                    ft.add(mContainerId, newTab.fragment, newTab.tag);
                } else {
//					ft.attach(newTab.fragment);
                    ft.show(newTab.fragment);
                }
            }

            mLastTab = newTab;
        }
        return ft;
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:38,代碼來源:FragmentTabHost.java


注:本文中的android.support.v4.app.FragmentTransaction.hide方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。