本文整理汇总了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);
}
}
示例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);
}
示例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();
}
}
示例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();
}
}
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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: ");
}
示例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);
}
示例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;
}