當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。