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


Java FragmentTransaction.addToBackStack方法代码示例

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


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

示例1: showDialog

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void showDialog(Bundle bundle) {
    final Activity activity = (Activity) context;
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    Fragment prev = activity.getFragmentManager().findFragmentByTag(fragmentTag);
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    newFragment = MyDialogFragment.newInstance(bundle);
    newFragment.setList(list);
    newFragment.setContext(context);
    newFragment.setListener(listener);
    newFragment.show(ft, fragmentTag);

}
 
开发者ID:icaynia,项目名称:pracler,代码行数:17,代码来源:SelectPopup.java

示例2: onNavigationItemSelected

import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
 * Metodo encargado de la navegacion. Usa item.getTitle para manejar el caso de intentar
 * navegar hacia la tab en la que ya estamos
 * @param item
 * @return true si se marca la tab, false si no
 */
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    Fragment newFragment = null;
    if(!(tabActualTitle == item.getTitle())){
        tabActualTitle = item.getTitle();
        switch (item.getItemId()) {
            case R.id.action_sofa:
                newFragment = Sofa.newInstance();
                break;
            case R.id.action_torneo:
                newFragment = Torneo.newInstance();
                break;
            case R.id.action_mapas:
                newFragment = Mapas.newInstance();
                break;
        }
        FragmentTransaction transaction = context.getFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment, newFragment);
        transaction.addToBackStack(null);
        transaction.commit();
        return true;
    }else{
        return false;
    }
}
 
开发者ID:cyanide4all,项目名称:MySmashCouch,代码行数:32,代码来源:CustomNavigationListener.java

示例3: switchToRegistration

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void switchToRegistration() {
    FragmentTransaction ft = fragmentManager.beginTransaction();

    RegistrationFragment registrationFragment = (RegistrationFragment) fragmentManager.findFragmentByTag(REGISTER_FRAGMENT_TAG);

    if (registrationFragment == null) {
        registrationFragment = RegistrationFragment.newInstance();
    }

    ft.replace(R.id.fragmentContainer, registrationFragment, REGISTER_FRAGMENT_TAG);
    ft.addToBackStack(REGISTER_FRAGMENT_TAG);
    ft.commit();
}
 
开发者ID:VidyaSastry,项目名称:Opal-Chat-AnalyticsDashboard,代码行数:15,代码来源:LoginActivity.java

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

示例5: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void show(FragmentManager manager, String tag) {
    if (!mDismissed) {
        return;
    }
    mDismissed = false;
    FragmentTransaction ft = manager.beginTransaction();
    ft.add(this, tag);
    ft.addToBackStack("actionSheet");
    ft.commit();
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:11,代码来源:ActionSheet.java

示例6: showEula

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void showEula(Activity activity) {
    FragmentManager fm = activity.getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    Fragment prev = fm.findFragmentByTag("dialog_eula");
    if (prev != null) {
        ft.remove(prev);
    }
    ft.addToBackStack(null);

    new EulaDialog().show(ft, "dialog_eula");
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:12,代码来源:AboutUtils.java

示例7: onCreate

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


    FragmentTransaction ft = getFragmentManager().beginTransaction();
    Fragment fragment = new FragmentFeed();
    ft.addToBackStack(null);
    ft.replace(R.id.content_main, fragment).commit();



    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });


    DrawerLayout 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 = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);


}
 
开发者ID:amigodeumamigomeu,项目名称:android-app-aam,代码行数:37,代码来源:MainActivity.java

示例8: replaceHasHistory

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void replaceHasHistory(int containerId, Fragment fragment) {
    if (currentFragment==fragment) {
        return;
    }
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(containerId, fragment);
    ft.addToBackStack(null);//添加这个会在按返回键的时候先退出fragment,一些特殊场合可能用到,但效果其实不理想
    ft.commitAllowingStateLoss();
    currentFragment = fragment;
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:11,代码来源:FragmentUtil.java

示例9: showPasswordResetFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void showPasswordResetFragment() {
    final FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out, R.animator.slide_in_left, R.animator.slide_out_right);
    transaction.add(R.id.fragment_container, new DCResetPasswordFragment());
    transaction.addToBackStack(DCResetPasswordFragment.TAG);
    transaction.commit();
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:8,代码来源:DCAuthenticationActivity.java

示例10: onScanFinish

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onScanFinish(Uri uri) {
    ResultFragment fragment = new ResultFragment();
    Bundle bundle = new Bundle();
    bundle.putParcelable(ScanConstants.SCANNED_RESULT, uri);
    fragment.setArguments(bundle);
    android.app.FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(cordova.getActivity().getResources().getIdentifier("content", "id", cordova.getActivity().getPackageName()) , fragment);
    fragmentTransaction.addToBackStack(ResultFragment.class.toString());
    fragmentTransaction.commit();
}
 
开发者ID:mohammedirfan655,项目名称:document-scanner,代码行数:13,代码来源:ScanActivity.java

示例11: changeFragmentForTablets

import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void changeFragmentForTablets(Fragment newFragment, FragmentsAvailable newFragmentType, boolean withoutAnimation) {
	if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
		if (newFragmentType == FragmentsAvailable.DIALER) {
			showStatusBar();
		} else {
			hideStatusBar();
		}
	}
	emptyFragment = false;
	LinearLayout ll = (LinearLayout) findViewById(R.id.fragmentContainer2);

	FragmentTransaction transaction = getFragmentManager().beginTransaction();

	if(newFragmentType == FragmentsAvailable.EMPTY){
		ll.setVisibility(View.VISIBLE);
		emptyFragment = true;
		transaction.replace(R.id.fragmentContainer2, newFragment);
		transaction.commitAllowingStateLoss();
		getFragmentManager().executePendingTransactions();
	} else {
		if (newFragmentType.shouldAddItselfToTheRightOf(currentFragment)) {
			ll.setVisibility(View.VISIBLE);

			if (newFragmentType == FragmentsAvailable.CONTACT_EDITOR) {
				transaction.addToBackStack(newFragmentType.toString());
			}
			transaction.replace(R.id.fragmentContainer2, newFragment);
		} else {
			if (newFragmentType == FragmentsAvailable.EMPTY) {
				ll.setVisibility(View.VISIBLE);
				transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
				emptyFragment = true;
			}

			if (newFragmentType == FragmentsAvailable.DIALER
					|| newFragmentType == FragmentsAvailable.ABOUT
					|| newFragmentType == FragmentsAvailable.SETTINGS
					|| newFragmentType == FragmentsAvailable.ACCOUNT_SETTINGS) {
				ll.setVisibility(View.GONE);
			} else {
				ll.setVisibility(View.VISIBLE);
				transaction.replace(R.id.fragmentContainer2, new EmptyFragment());
			}

			/*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);
				}
			}*/
			transaction.replace(R.id.fragmentContainer, newFragment);
		}
		transaction.commitAllowingStateLoss();
		getFragmentManager().executePendingTransactions();

		currentFragment = newFragmentType;
		if (newFragmentType == FragmentsAvailable.DIALER
				|| newFragmentType == FragmentsAvailable.SETTINGS
				|| newFragmentType == FragmentsAvailable.CONTACTS_LIST
				|| newFragmentType == FragmentsAvailable.CHAT_LIST
				|| newFragmentType == FragmentsAvailable.HISTORY_LIST) {
			try {
				getFragmentManager().popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
			} catch (IllegalStateException e) {

			}
		}
		fragmentsHistory.add(currentFragment);
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:72,代码来源:LinphoneActivity.java

示例12: show

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void show(FragmentManager manager) {
    FragmentTransaction ft = manager.beginTransaction();
    ft.add(this, getTagName());
    ft.addToBackStack(getTagName());
    ft.commit();

}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:8,代码来源:LittleWindow.java

示例13: showCollectDCN

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void showCollectDCN() {
    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 DCCollectDCNFragment());
    transaction.addToBackStack(DCCollectDCNFragment.TAG);
    transaction.commit();
}
 
开发者ID:Dentacoin,项目名称:aftercare-app-android,代码行数:8,代码来源:DCCollectActivity.java

示例14: switchFragment

import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void switchFragment(FragmentManager fragmentManager, Fragment fragment, int containViewId, boolean addToBackStack)
	{
//		fragments.add(new WeakReference<Fragment>(fragment));
//		
//		FragmentTransaction transaction = fragmentManager.beginTransaction();
//		transaction.replace(containViewId, fragment);
////		transaction.replace(containViewId, fragment, fragment.getClass().toString());
//		if (addToBackStack)
//		{
//			backStackIndex++;
//			String key = "" + backStackIndex;
//			transaction.addToBackStack(key);
//			backStackKeys.add(key);
//		}
//		else
//		{
////			transaction.addToBackStack(null);
//		}
//		
//		transaction.commit();
		
		boolean isContain = false;
		for (int i = 0; i < fragments.size(); i++){
			if (fragments.get(i).get() != null && fragments.get(i).get().getClass() == fragment.getClass()){
				isContain = true;
				break;
			}
		}
		if (!isContain){
			fragments.add(new WeakReference<Fragment>(fragment));
		}
		
		if (fragment.getView() != null){
			fragment.getView().setClickable(true);
		}
		
		FragmentTransaction transaction = fragmentManager.beginTransaction();
		if (addToBackStack)
		{
			backStackIndex++;
			String key = "" + backStackIndex;
			transaction.addToBackStack(key);
			backStackKeys.add(key);
			
		}
		else
		{
//			transaction.addToBackStack(null);
		}
		transaction.replace(containViewId, fragment, ""+backStackIndex);
		transaction.commitAllowingStateLoss();
	}
 
开发者ID:WowWeeLabs,项目名称:CHIP-Android-SDK,代码行数:53,代码来源:FragmentHelper.java

示例15: onClick

import android.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
    int scenario = -1;
    switch (getAdapterPosition()) {
        case 0:
            if (currentMeasure != null) {
                switch (currentMeasure.getEscenarioStateToday()) {
                    case "NONE":
                        scenario = 0;
                        break;
                    case "ESCENARIO1":
                        scenario = 1;
                        break;
                    case "ESCENARIO2":
                        scenario = 2;
                        break;
                    case "ESCENARIO3":
                        scenario = 3;
                        break;
                    case "ESCENARIO4":
                        scenario = 4;
                        break;
                }
            }
            showDialogScenario(scenario,true);
            break;
        case 1:
            if (currentMeasure != null) {
                switch (currentMeasure.getEscenarioStateTomorrow()) {
                    case "NONE":
                        scenario = 0;
                        break;
                    case "ESCENARIO1":
                        scenario = 1;
                        break;
                    case "ESCENARIO2":
                        scenario = 2;
                        break;
                    case "ESCENARIO3":
                        scenario = 3;
                        break;
                    case "ESCENARIO4":
                        scenario = 4;
                        break;
                }
            }
            showDialogScenario(scenario,false);
            break;
        case 2:
            FragmentManager fragmentManager = mActivity.getFragmentManager();
            String fragment_tag = MyMapFragment.class.getName();
            Fragment fragment = fragmentManager.findFragmentByTag(fragment_tag);
            if (fragment == null) {
                fragment = new MyMapFragment();
            }
            FragmentTransaction transaction = fragmentManager.beginTransaction();
            transaction.replace(R.id.content_frame, fragment, fragment_tag);
            transaction.addToBackStack(null);
            transaction.commit();
            break;
        case 3:
            DownloadFilesUtils.downloadPdf(mActivity, mActivity, DownloadFilesUtils.EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE_BOLETIN_DIARIO);
    }
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:65,代码来源:MainRecyclerAdapter.java


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