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


Java FragmentTransaction.replace方法代码示例

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


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

示例1: onCreate

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    FragmentTransaction transaction =getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.home_fragment_container, new ImageListFragment());
    transaction.commit();
    share = (FloatingActionButton) findViewById(R.id.home_share);
    share.setRippleColor(Color.BLUE);
    share.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent loginActivityIntent = new Intent(HomeActivity.this, ShareImageActivity.class);
            startActivity(loginActivityIntent);
        }
    });
}
 
开发者ID:hphamid,项目名称:maktabkhoone-instagram,代码行数:18,代码来源:HomeActivity.java

示例2: onClickSignIn

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@OnClick(R.id.signup_signin_textview)
public void onClickSignIn() {
    if (CredentialManager.getAccounts().size() == 0) {
        new AlertDialog.Builder(getActivity())
                .setTitle("No Account")
                .setMessage("There is no account. Please create a new one.")
                .setPositiveButton("Ok", null)
                .show();
        return;
    }
    //TODO Move To SignIn Fragment
    Fragment frag = new SignInListFragment();
    FragmentManager fmanager = getActivity().getSupportFragmentManager();
    FragmentTransaction ftrans = fmanager.beginTransaction();
    ftrans.replace(R.id.fragment_framelayout, frag);
    ftrans.addToBackStack(null);
    ftrans.commit();
}
 
开发者ID:SlotNSlot,项目名称:SlotNSlot_Android,代码行数:19,代码来源:SignUpFragment.java

示例3: afterActivityLaunched

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
protected void afterActivityLaunched() {
    super.afterActivityLaunched();

    try {
        //Instantiate and insert the fragment into the container layout
        FragmentManager manager = getActivity().getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        mFragment = mFragmentClass.newInstance();
        transaction.replace(R.id.container, mFragment);
        transaction.commit();
    } catch (InstantiationException | IllegalAccessException e) {
        Assert.fail(String.format("%s: Could not insert %s into TestActivity: %s",
                getClass().getSimpleName(),
                mFragmentClass.getSimpleName(),
                e.getMessage()));
    }
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:19,代码来源:FragmentTestRule.java

示例4: loadHomeFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
/***
 * Returns respected fragment that user
 * selected from navigation menu
 */
private void loadHomeFragment() {
    selectNavMenu();
    setToolbarTitle();
    if (getSupportFragmentManager().findFragmentByTag(CURRENT_TAG) != null) {
        drawer.closeDrawers();
        return;
    }
    Runnable mPendingRunnable = new Runnable() {
        @Override
        public void run() {
            // update the main content by replacing fragments
            Fragment fragment = getHomeFragment();
            FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
            fragmentTransaction.setCustomAnimations(android.R.anim.fade_in,
                    android.R.anim.fade_out);
            fragmentTransaction.replace(R.id.frame, fragment, CURRENT_TAG);
            fragmentTransaction.commitAllowingStateLoss();
        }
    };
    if (mPendingRunnable != null) {
        mHandler.post(mPendingRunnable);
    }
    drawer.closeDrawers();
    invalidateOptionsMenu();
}
 
开发者ID:ProjektMedInf,项目名称:WiFiSDCryptoLocker,代码行数:30,代码来源:MainActivity.java

示例5: onCreate

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_form_fragment_activity);

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(R.id.fragment_container, new FormFragment());
    fragmentTransaction.commit();
}
 
开发者ID:pchmn,项目名称:AndroidVerify,代码行数:10,代码来源:FormFragmentActivity.java

示例6: showLoopModeCheck

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void showLoopModeCheck()
{
    final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.replace(R.id.fragment_content, RMBTCheckFragment.newInstance(CheckType.LOOP_MODE, CheckType.LOOP_MODE2), AppConstants.PAGE_TITLE_LOOP_MODE_CHECK);
    ft.addToBackStack(AppConstants.PAGE_TITLE_LOOP_MODE_CHECK);
    ft.commit();
    setTitle(AppConstants.PAGE_TITLE_LOOP_MODE_CHECK);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:9,代码来源:RMBTTermsActivity.java

示例7: startLoopTest

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void startLoopTest() {
	startLoopService();
	
    FragmentTransaction ft;
    ft = fm.beginTransaction();
    final LoopModeTestFragment rmbtTestFragment = new LoopModeTestFragment();
    ft.replace(R.id.fragment_content, rmbtTestFragment, AppConstants.PAGE_TITLE_LOOP_TEST);
    ft.addToBackStack(AppConstants.PAGE_TITLE_LOOP_TEST);
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    fm.popBackStack();
    ft.commit();
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:13,代码来源:RMBTMainActivity.java

示例8: setFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
private void setFragment(Fragment fragment, String fragmentTag) {
    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace(
            R.id.content_main,
            fragment,
            fragmentTag);
    fragmentTransaction.commitAllowingStateLoss();
}
 
开发者ID:erdo,项目名称:asaf-project,代码行数:9,代码来源:FruitActivity.java

示例9: replaceFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
void replaceFragment(Fragment newFragment, String stackName, Bundle extras) {
    if (extras != null) {
        newFragment.setArguments(extras);
    }
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.fragment_container, newFragment);
    transaction.addToBackStack(stackName);
    transaction.commit();
}
 
开发者ID:m2049r,项目名称:xmrwallet,代码行数:10,代码来源:LoginActivity.java

示例10: replaceFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void replaceFragment(int id, Fragment fragment, boolean isBackStack) {
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.replace(id, fragment);
    if (isBackStack) {
        fragmentTransaction.addToBackStack(fragment.getClass().getName());
    }
    fragmentTransaction.commitAllowingStateLoss();
}
 
开发者ID:harrylefit,项目名称:eazycore,代码行数:10,代码来源:FragmentHelper.java

示例11: showMap

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void showMap(boolean popBackStack) {

        // Amazon Fire devices do not support Google Maps, thus fall back to browser map

        // identify Amazon Fire devices
        final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";

        if (getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV)) {
            Log.d(DEBUG_TAG, "This is a Fire TV device: " + Build.MODEL);

            String url = this.getString(R.string.url_map);
            showUrl(url, popBackStack, AppConstants.PAGE_TITLE_MAP);
        }
        else { // show native map
            if (popBackStack) {
                popBackStackFull();
            }

            FragmentTransaction ft;
            ft = fm.beginTransaction();
            Fragment f = new RMBTMapFragment();
            Bundle bundle = new Bundle();
            bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_ALL_GESTURES, true);
            bundle.putBoolean(RMBTMapFragment.OPTION_SHOW_INFO_TOAST, true);
            bundle.putBoolean(RMBTMapFragment.OPTION_ENABLE_CONTROL_BUTTONS, true);
            f.setArguments(bundle);
            ft.replace(R.id.fragment_content, f, AppConstants.PAGE_TITLE_MAP);
            ft.addToBackStack(AppConstants.PAGE_TITLE_MAP);
            ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
            ft.commit();

            refreshActionBar(AppConstants.PAGE_TITLE_MAP);
        }
    }
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:35,代码来源:RMBTMainActivity.java

示例12: onPreferenceClick

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public boolean onPreferenceClick(Preference preference) {
  Fragment            fragment            = new MmsPreferencesFragment();
  FragmentManager     fragmentManager     = getActivity().getSupportFragmentManager();
  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
  fragmentTransaction.replace(android.R.id.content, fragment);
  fragmentTransaction.addToBackStack(null);
  fragmentTransaction.commit();

  return true;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:SmsMmsPreferenceFragment.java

示例13: changeFragment

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
public void changeFragment(int id, Fragment fragment) {
    FragmentManager fragmentManager = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    fragmentTransaction.replace(id, fragment);
    fragmentTransaction.commit();
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:8,代码来源:BaseActivity.java

示例14: onListFragmentInteraction

import android.support.v4.app.FragmentTransaction; //导入方法依赖的package包/类
@Override
public void onListFragmentInteraction(String address) {
    mCurrentFragment = DeviceFragment.newInstance(address);
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    transaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left);
    transaction.replace(R.id.container, mCurrentFragment);
    transaction.addToBackStack(null);
    transaction.commit();
}
 
开发者ID:martindisch,项目名称:SensorTag-Accelerometer,代码行数:10,代码来源:MainActivity.java

示例15: onCreate

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

   DaggerAppComponent.create().inject(this);

    ((TextView)this.findViewById(R.id.header)).setText(storeMessage.getMsg());

    fm = getSupportFragmentManager();

    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.content, new StoreFragment());
    ft.commit();
}
 
开发者ID:srinurp,项目名称:DaggerSubcomponents,代码行数:16,代码来源:MainActivity.java


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