当前位置: 首页>>代码示例>>Java>>正文


Java FragmentTransaction.show方法代码示例

本文整理汇总了Java中android.support.v4.app.FragmentTransaction.show方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTransaction.show方法的具体用法?Java FragmentTransaction.show怎么用?Java FragmentTransaction.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.FragmentTransaction的用法示例。


在下文中一共展示了FragmentTransaction.show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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,项目名称:ShaddockVideoPlayer,代码行数:26,代码来源:FragmentUtils.java

示例2: showOneFragmentOnBackPressed

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * 返回键显示特定Tag的Fragment
 */
private void showOneFragmentOnBackPressed() {
    mFragmentBackDeque.pop();
    String fragmentTab = mFragmentBackDeque.peek();

    FragmentManager manager = getSupportFragmentManager();
    if (manager != null) {
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.setCustomAnimations(R.anim.left_enter, R.anim.right_exit, 0, 0);

        List<Fragment> fragments = manager.getFragments();
        for (Fragment f : fragments) {
            if (f != null) {
                transaction.hide(f);
            }
        }
        Fragment fragmentByTag = manager.findFragmentByTag(fragmentTab);
        if (fragmentByTag != null) {
            mCurrentFragment = fragmentByTag;
            transaction.show(fragmentByTag);
        }

        transaction.commitAllowingStateLoss();
    }
}
 
开发者ID:Sugarya,项目名称:Closet,代码行数:28,代码来源:BasicActivity.java

示例3: switchFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment(BaseFragment fragment) {
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    for (int i = 0; i < this.mFragments.size(); i++) {
        BaseFragment item = (BaseFragment) this.mFragments.get(i);
        this.currentIndex = i;
        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,代码行数:18,代码来源:TopicActivity.java

示例4: 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

示例5: showFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void showFragment(int index) {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    hideFragment(ft);
    switch (index) {
        case 0:
            if (mHomeFragment == null) {
                mHomeFragment = new HomeFragment();
                ft.add(R.id.main_content, mHomeFragment);
            } else {
                ft.show(mHomeFragment);
            }
            break;
        case 1:
            if (mGameTypeFragment == null) {
                mGameTypeFragment = new GameTypeFragment();
                ft.add(R.id.main_content, mGameTypeFragment);
            } else {
                ft.show(mGameTypeFragment);
            }
            break;
        case 2:
            if (mSearchFragment == null) {
                mSearchFragment = new DiscoveryFragment();
                ft.add(R.id.main_content, mSearchFragment);
            } else {
                ft.show(mSearchFragment);
            }
            break;
        case 3:
            if (mMeFragment == null) {
                mMeFragment = new MeFragment();
                ft.add(R.id.main_content, mMeFragment);
            } else {
                ft.show(mMeFragment);
            }
            break;
    }
    ft.commit();
}
 
开发者ID:yinyiliang,项目名称:RabbitCloud,代码行数:40,代码来源:MainActivity.java

示例6: onBackPressed

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
        mDrawerLayout.closeDrawer(GravityCompat.START);
    } else if (mFragmentStack.size() > 1) {
        FragmentTransaction fragmentTransaction =
                getSupportFragmentManager().beginTransaction();
        if (mCurrentFragmentId != NAVIGATE_ID && mCurrentFragmentId != DETAILS_ISSUE_ID
                && mCurrentFragmentId != DETAILS_QR_ID && mCurrentFragmentId != DETAILS_AWARD_ID
                && mCurrentFragmentId != DETAILS_ACHIEVEMENTS_ID
                && mCurrentFragmentId != DETAILS_EVENTS_ID) {
            BasicFragment fragment = (BasicFragment) mFragmentStack.pop();
            fragmentTransaction.remove(fragment);
            while (fragment.getFragmentId() != NAVIGATE_ID) {
                fragment = (BasicFragment) mFragmentStack.pop();
            }
            mFragmentStack.clear();
            mFragmentStack.add(fragment);
            fragment.onResume();
            fragmentTransaction.show(fragment).commit();
            mCurrentFragmentId = NAVIGATE_ID;
            mCurrentFragment = fragment;
        } else {
            mFragmentStack.lastElement().onPause();
            fragmentTransaction.remove(mFragmentStack.pop());
            mFragmentStack.lastElement().onResume();
            BasicFragment restoredFragment = (BasicFragment) mFragmentStack.lastElement();
            fragmentTransaction.show(restoredFragment);
            fragmentTransaction.commit();
            mCurrentFragment = restoredFragment;
            mCurrentFragmentId = restoredFragment.getFragmentId();
        }
        setToolbarTitle();
        updateMenu();
        updateDrawerMenu();
    } else {
        super.onBackPressed();
    }
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:40,代码来源:DrawerActivity.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: 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:angcyo,项目名称:RLibrary,代码行数:15,代码来源:FragmentChangeManager.java

示例9: showTab

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void showTab(int idx) {
	for (int i = 0; i < fragments.size(); i++) {
		Fragment fragment = fragments.get(i);
		FragmentTransaction ft = obtainFragmentTransaction(idx);

		if (idx == i) {
			ft.show(fragment);
		} else {
			ft.hide(fragment);
		}
		ft.commit();
	}
	currentTab = idx; 
}
 
开发者ID:xdstudent,项目名称:ZhiHuIndex-master,代码行数:15,代码来源:FragmentTabAdapter.java

示例10: 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();
    }
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:16,代码来源:BaseFragment.java

示例11: showBookmarksFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void showBookmarksFragment() {

        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        fragmentTransaction.show(bookmarksFragment);
        fragmentTransaction.hide(mainFragment);
        fragmentTransaction.commit();

        toolbar.setTitle(getResources().getString(R.string.nav_bookmarks));

        if (bookmarksFragment.isAdded()) {
            bookmarksFragment.notifyDataChanged();
        }

    }
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:15,代码来源:MainActivity.java

示例12: showPackagesFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * Show the packages list fragment.
 */
private void showPackagesFragment() {

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.show(packagesFragment);
    fragmentTransaction.hide(companiesFragment);
    fragmentTransaction.commit();

    toolbar.setTitle(getResources().getString(R.string.app_name));
    navigationView.setCheckedItem(R.id.nav_home);

}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:15,代码来源:MainActivity.java

示例13: showCompaniesFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * Show the companies list fragment.
 */
private void showCompaniesFragment() {

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.show(companiesFragment);
    fragmentTransaction.hide(packagesFragment);
    fragmentTransaction.commit();

    toolbar.setTitle(getResources().getString(R.string.nav_companies));
    navigationView.setCheckedItem(R.id.nav_companies);

}
 
开发者ID:TonnyL,项目名称:Espresso,代码行数:15,代码来源:MainActivity.java

示例14: showMediaPreviewFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void showMediaPreviewFragment() {
    mSelectedIndex = 2;
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    mMediaPreviewFragment = MediaPreviewFragment.newInstance(mConfiguration, mPreviewPosition);
    ft.add(R.id.fragment_container, mMediaPreviewFragment);
    mMediaPageFragment = null;
    ft.hide(mMediaGridFragment);
    ft.show(mMediaPreviewFragment);
    ft.commit();

    String title = getString(R.string.gallery_page_title, mPreviewPosition, mCheckedList.size());
    mTvToolbarTitle.setText(title);
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:15,代码来源:MediaActivity.java

示例15: 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


注:本文中的android.support.v4.app.FragmentTransaction.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。