本文整理了Java中android.app.FragmentTransaction.commit()
方法的一些代码示例,展示了FragmentTransaction.commit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentTransaction.commit()
方法的具体详情如下:
包路径:android.app.FragmentTransaction
类名称:FragmentTransaction
方法名:commit
暂无
代码示例来源:origin: android10/Android-CleanArchitecture
/**
* Adds a {@link Fragment} to this activity's layout.
*
* @param containerViewId The container view to where add the fragment.
* @param fragment The fragment to be added.
*/
protected void addFragment(int containerViewId, Fragment fragment) {
final FragmentTransaction fragmentTransaction = this.getFragmentManager().beginTransaction();
fragmentTransaction.add(containerViewId, fragment);
fragmentTransaction.commit();
}
代码示例来源:origin: robolectric/robolectric
public static void startVisibleFragment(Fragment fragment,
Class<? extends Activity> activityClass, int containerViewId) {
buildFragmentManager(activityClass)
.beginTransaction().add(containerViewId, fragment, null).commit();
}
代码示例来源:origin: robolectric/robolectric
public static void startFragment(Fragment fragment) {
buildFragmentManager(FragmentUtilActivity.class)
.beginTransaction().add(fragment, null).commit();
}
代码示例来源:origin: robolectric/robolectric
public static void startFragment(Fragment fragment, Class<? extends Activity> activityClass) {
buildFragmentManager(activityClass)
.beginTransaction().add(fragment, null).commit();
}
代码示例来源:origin: robolectric/robolectric
public static void startVisibleFragment(Fragment fragment) {
buildFragmentManager(FragmentUtilActivity.class)
.beginTransaction().add(1, fragment, null).commit();
}
代码示例来源:origin: robolectric/robolectric
@Override
public void run() {
activityController.create(bundle).get().getFragmentManager().beginTransaction().add(contentViewId, fragment).commit();
}
});
代码示例来源:origin: TeamNewPipe/NewPipe
private void updateFragments() {
MissionsFragment fragment = new MissionsFragment();
getFragmentManager().beginTransaction()
.replace(R.id.frame, fragment, MISSIONS_FRAGMENT_TAG)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content)==null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new Prefs()).commit();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new ThingsFragment()).commit();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content)==null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new SettingsFragment()).commit();
}
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content)==null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new Prefs()).commit();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getFragmentManager().findFragmentById(android.R.id.content)==null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new Prefs()).commit();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void wordClicked() {
if (stuff == null) {
stuff=new StuffFragment();
}
getFragmentManager().beginTransaction()
.replace(R.id.content, stuff)
.addToBackStack(null).commit();
drawer.post(onNavChange);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onConnected(Bundle bundle) {
if (getFragmentManager().findFragmentById(android.R.id.content) == null) {
getFragmentManager().beginTransaction()
.add(android.R.id.content,
new WeatherFragment()).commit();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
details=
(DetailsFragment)getFragmentManager().findFragmentById(R.id.details);
if (details == null && findViewById(R.id.details) != null) {
details=new DetailsFragment();
getFragmentManager().beginTransaction()
.add(R.id.details, details).commit();
}
}
代码示例来源:origin: robolectric/robolectric
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FragmentManager fragmentManager = this.getFragmentManager();
TestPreferenceFragment fragment = new TestPreferenceFragment();
fragmentManager.beginTransaction().replace(android.R.id.content, fragment, FRAGMENT_TAG).commit();
}
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void testDoesNotThrowIfAskedToGetManagerForFragmentPreJellyBeanMr1() {
Util.setSdkVersionInt(Build.VERSION_CODES.JELLY_BEAN);
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, "test").commit();
android.app.Fragment spyFragment = Mockito.spy(fragment);
when(spyFragment.getChildFragmentManager()).thenThrow(new NoSuchMethodError());
assertNotNull(retriever.get(spyFragment));
}
代码示例来源:origin: bumptech/glide
public RequestManagerHarness() {
fragment = new RequestManagerFragment(lifecycle);
controller = Robolectric.buildActivity(Activity.class).create();
controller.get()
.getFragmentManager()
.beginTransaction()
.add(fragment, TAG)
.commit();
controller.get()
.getFragmentManager()
.executePendingTransactions();
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
@Test
public void testCanGetRequestManagerFromFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, PARENT_TAG).commit();
activity.getFragmentManager().executePendingTransactions();
RequestManager manager = retriever.get(fragment);
assertEquals(manager, retriever.get(fragment));
}
代码示例来源:origin: bumptech/glide
@SuppressWarnings("deprecation")
private void helpTestCanGetRequestManagerFromDetachedFragment() {
Activity activity = Robolectric.buildActivity(Activity.class).create().start().resume().get();
android.app.Fragment fragment = new android.app.Fragment();
activity.getFragmentManager().beginTransaction().add(fragment, PARENT_TAG).detach(fragment)
.commit();
activity.getFragmentManager().executePendingTransactions();
assertTrue(fragment.isDetached());
retriever.get(fragment);
}
内容来源于网络,如有侵权,请联系作者删除!