本文整理汇总了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);
}
});
}
示例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();
}
示例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()));
}
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}