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


Java FragmentTransaction.replace方法代码示例

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


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

示例1: onNavigationItemSelected

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.navigation_home:
            FragmentManager manager = getFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            transaction.replace(R.id.content, ProjectFragment.newInstance()); // newInstance() is a static factory method.
            transaction.commit();
            return true;
        case R.id.navigation_dashboard:
            FragmentManager newsManager = getFragmentManager();
            FragmentTransaction transaction1 = newsManager.beginTransaction();
            transaction1.replace(R.id.content, OrgFragment.newInstance()); // newInstance() is a static factory method.
            transaction1.commit();
            return true;
        case R.id.navigation_notifications:
            FragmentManager projectManager = getFragmentManager();
            FragmentTransaction transaction2 = projectManager.beginTransaction();
            transaction2.replace(R.id.content, MapFragment.newInstance()); // newInstance() is a static factory method.
            transaction2.commit();
            return true;
    }
    return false;
}
 
开发者ID:techstar-cloud,项目名称:techstar-org,代码行数:25,代码来源:MainActivity.java

示例2: goToRegister

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

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        RegisterFragment fragment = new RegisterFragment();
        ft.replace(R.id.fragmentFrame,fragment,RegisterFragment.TAG);
        ft.commit();
    }
 
开发者ID:EdwardAlexis,项目名称:Sistema-de-Comercializacion-Negocios-Jhordan,代码行数:8,代码来源:LoginFragment.java

示例3: goToLogin

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

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        LoginFragment fragment = new LoginFragment();
        ft.replace(R.id.fragmentFrame, fragment, LoginFragment.TAG);
        ft.commit();
    }
 
开发者ID:EdwardAlexis,项目名称:Sistema-de-Comercializacion-Negocios-Jhordan,代码行数:8,代码来源:RegisterFragment.java

示例4: changeFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void changeFragment(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	FragmentManager fm = getFragmentManager();
	FragmentTransaction transaction = fm.beginTransaction();

	/*if (!withoutAnimation && !isAnimationDisabled && currentFragment.shouldAnimate()) {
		if (newFragmentType.isRightOf(currentFragment)) {
			transaction.setCustomAnimations(R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left,
					R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right);
		} else {
			transaction.setCustomAnimations(R.anim.slide_in_left_to_right,
					R.anim.slide_out_left_to_right,
					R.anim.slide_in_right_to_left,
					R.anim.slide_out_right_to_left);
		}
	}*/

	if (newFragmentType != FragmentsAvailable.DIALER
			&& newFragmentType != FragmentsAvailable.CONTACTS_LIST
			&& newFragmentType != FragmentsAvailable.CHAT_LIST
			&& newFragmentType != FragmentsAvailable.HISTORY_LIST) {
		transaction.addToBackStack(newFragmentType.toString());
	} else {
		while (fm.getBackStackEntryCount() > 0) {
			fm.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
		}
	}

	transaction.replace(R.id.fragmentContainer, newFragment, newFragmentType.toString());
	transaction.commitAllowingStateLoss();
	fm.executePendingTransactions();

	currentFragment = newFragmentType;
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:36,代码来源:LinphoneActivity.java

示例5: onCreate

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    navigation = (BottomNavigationView) findViewById(R.id.navigation);
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);


    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.content, ProjectFragment.newInstance()); // newInstance() is a static factory method.
    transaction.commit();

    shakeSensor = new ShakeSensor();
    shakeSensor.setListener(this);
    shakeSensor.init(this);

}
 
开发者ID:doljko,项目名称:youth-health,代码行数:31,代码来源:MainActivity.java

示例6: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm, String mimeType, String displayName) {
	final Bundle args = new Bundle();
	args.putString(EXTRA_MIME_TYPE, mimeType);
	args.putString(EXTRA_DISPLAY_NAME, displayName);

	final SaveFragment fragment = new SaveFragment();
	fragment.setArguments(args);

	final FragmentTransaction ft = fm.beginTransaction();
	ft.replace(R.id.container_save, fragment, TAG);
	ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:13,代码来源:SaveFragment.java

示例7: setBodyFrontBack

import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * 设置人体正反面
 * @author leibing
 * @createTime 2016/10/07
 * @lastModify 2016/10/07
 * @param
 * @return
 */
private void setBodyFrontBack() {
    switch (curSexFace){
        case MAN_FRONT:
            // 当为男性正面,则设置为男性反面
            curSexFace = MAN_BACK;
            break;
        case MAN_BACK:
            // 当为男性反面,则设置为男性正面
            curSexFace = MAN_FRONT;
            break;
        case WOMEN_FRONT:
            // 当为女性正面,则设置为女性反面
            curSexFace = WOMEN_BACK;
            break;
        case WOMEN_BACK:
            // 当为女性反面,则设置为女性正面
            curSexFace = WOMEN_FRONT;
            break;
    }

    if (curSexFace == MAN_FRONT || curSexFace == WOMEN_FRONT){
        // 当前面为男性正面或女性正面均设置为正面
        reverseTv.setText("正面");
    }else if (curSexFace == MAN_BACK || curSexFace == WOMEN_BACK){
        // 当前面为男性反面或女性反面均设置为反面
        reverseTv.setText("反面");
    }

    // 执行动画更新fragment内容
    FragmentTransaction fm = getFragmentManager().beginTransaction();
    fm.setCustomAnimations(R.anim.animator_two_enter, R.anim.animator_one_exit);
    fragmentHumanBody = HumanBodyFragment.newInstance(curSexFace);
    fm.replace(R.id.ly_fragment_area, fragmentHumanBody, "FragmentHumanBody");
    fm.commit();
}
 
开发者ID:leibing8912,项目名称:HumanBody,代码行数:44,代码来源:HumanBodyActivity.java

示例8: showFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void showFragment(Fragment fragment) {
    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
    fragmentTransaction.setCustomAnimations(
            R.animator.enter,
            R.animator.exit,
            R.animator.pop_enter,
            R.animator.pop_exit
    );
    fragmentTransaction.replace(R.id.products_activity_content, fragment);
    fragmentTransaction.addToBackStack("ProductsStack");
    fragmentTransaction.commit();
}
 
开发者ID:chicio,项目名称:Model-View-Presenter,代码行数:13,代码来源:ProductsActivity.java

示例9: switchMainView

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchMainView(AAttachableFragment fragment)
{
    FragmentManager manager = getFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();

    transaction.replace(R.id.fragment_container, fragment);
    transaction.commit();

    fragment.attach(this);
    this.lastMainFragment = fragment;
}
 
开发者ID:subchannel13,项目名称:EnchantedFortress,代码行数:12,代码来源:MainActivity.java

示例10: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm, RootInfo root) {
    final ServerFragment fragment = new ServerFragment();
    final Bundle args = new Bundle();
    args.putParcelable(EXTRA_ROOT, root);
    fragment.setArguments(args);
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_directory, fragment);
    ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:10,代码来源:ServerFragment.java

示例11: setBaseFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void setBaseFragment(Fragment fragment) {
    if (fragment == null) return;
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.base_fragment, fragment, BASE_FRAGMENT);
    transaction.commit();
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:7,代码来源:MainActivity.java

示例12: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void show(FragmentManager fm) {
    final HomeFragment fragment = new HomeFragment();
    final FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container_directory, fragment, TAG);
    ft.commitAllowingStateLoss();
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:7,代码来源:HomeFragment.java

示例13: loadHomeFragment

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

        HomeFragment fragment = HomeFragment.newInstance();
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.fragment_frame, fragment);
        ft.commit();
    }
 
开发者ID:Learn2Crack,项目名称:android-bottom-navigation-view,代码行数:8,代码来源:MainActivity.java

示例14: showSignupFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * Shows the signup fragment
 */
public void showSignupFragment() {
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.setCustomAnimations(R.animator.slide_in_right, R.animator.slide_out_left, R.animator.slide_in_left, R.animator.slide_out_right);
    transaction.replace(R.id.fragment_container, new DCSignupFragment());
    transaction.addToBackStack(DCSignupFragment.TAG);
    transaction.commit();
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:11,代码来源:DCAuthenticationActivity.java

示例15: switchFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void switchFragment(Fragment fragment)
{
    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.replace(R.id.content_main, fragment);
    transaction.commit();
}
 
开发者ID:XndroidDev,项目名称:Xndroid,代码行数:7,代码来源:MainActivity.java


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