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