当前位置: 首页>>代码示例>>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;未经允许,请勿转载。