本文整理汇总了Java中android.app.FragmentTransaction.remove方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentTransaction.remove方法的具体用法?Java FragmentTransaction.remove怎么用?Java FragmentTransaction.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.FragmentTransaction
的用法示例。
在下文中一共展示了FragmentTransaction.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void removeFragment(FragmentManager fragmentManager, int containViewId)
{
if(fragmentManager != null) {
Fragment fragment = fragmentManager.findFragmentById(containViewId);
if (fragment != null)
{
fragments.remove(fragment);
// TODO: Remove from backStackKeys
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.remove(fragment);
transaction.commitAllowingStateLoss();
}
}
else {
Log.e("FragmentHelper", "Fragment Manager = null");
}
}
示例2: 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("dialog2");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
ArrayList<String> list = (ArrayList<String>) bundle.get("adduid");
MyDialogFragment newFragment = MyDialogFragment.newInstance(bundle);
newFragment.setContext(context);
newFragment.setListener(listener);
newFragment.show(ft, "dialog2");
}
示例3: removeMessageViewFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
* Remove MessageViewFragment if necessary.
*/
private void removeMessageViewFragment() {
if (mMessageViewFragment != null) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.remove(mMessageViewFragment);
mMessageViewFragment = null;
ft.commit();
showDefaultTitleView();
}
}
示例4: removeFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
@SuppressWarnings("SameParameterValue")
private void removeFragment(final Fragment fragment, final boolean addToBackStack,
final boolean allowStateLoss) {
final FragmentManager fm = getFragmentManager();
final FragmentTransaction transaction = fm.beginTransaction();
final String tag;
if (fragment instanceof CurrentFeedFragment) {
tag = CurrentFeedFragment.TAG;
} else if (fragment instanceof FeedSubscriptionsFragment) {
tag = FeedSubscriptionsFragment.TAG;
} else if (fragment instanceof SavedEntriesFragment) {
tag = SavedEntriesFragment.TAG;
} else if (fragment instanceof InitialSetupFragment) {
tag = InitialSetupFragment.TAG;
} else {
tag = LoadCurrentFeedFragment.TAG;
}
transaction.remove(fragment);
if (addToBackStack) {
transaction.addToBackStack(tag);
}
if (allowStateLoss) {
transaction.commitAllowingStateLoss();
} else {
transaction.commit();
}
fm.executePendingTransactions();
}
示例5: dismiss
import android.app.FragmentTransaction; //导入方法依赖的package包/类
public void dismiss() {
if (mDismissed) {
return;
}
mDismissed = true;
getFragmentManager().popBackStack();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.remove(this);
ft.commit();
}
示例6: OnComplete
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
* Destroys fragment and resets UI after the user either cancels or finishes sending a story.
*/
public void OnComplete() {
FragmentManager manager = getFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.remove(manager.findFragmentByTag("AddStoryFragment_1"));
transaction.commit();
adapter.setcheck(false);
supportInvalidateOptionsMenu();
findViewById(R.id.go_to_map).setVisibility(View.VISIBLE);
findViewById(R.id.fab).setVisibility(View.VISIBLE);
}
示例7: showUserFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void showUserFragment(User user){
FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment prev = getFragmentManager().findFragmentByTag(USER_FRAGMENT_LABEL);
if(prev != null){
ft.remove(prev);
}
ft.addToBackStack(null);
UserFragment newFragment = UserFragment.newInstance(user);
newFragment.show(ft, USER_FRAGMENT_LABEL);
}
示例8: clearAllBackStackFragments
import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void clearAllBackStackFragments(FragmentManager fragmentManager)
{
FragmentTransaction ft = fragmentManager.beginTransaction();
for (WeakReference<Fragment> ref : fragments) {
Fragment fragment = ref.get();
if (fragment != null) {
ft.remove(fragment);
}
}
fragments.clear();
backStackKeys.clear();
ft.commitAllowingStateLoss();
}
示例9: setupTransaction
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
* Setup a base dialog fragment transaction. Handles the removing of a
* previous fragment if it exists and adds itself to the backstack.
*
* @return FragmentTransaction
*/
private FragmentTransaction setupTransaction(Activity activity) {
FragmentManager manager = activity.getFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
Fragment prev = manager.findFragmentByTag("dialog");
if (prev != null)
ft.remove(prev);
ft.addToBackStack(null);
return ft;
}
示例10: removeAll
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**清空所有fragment*/
public void removeAll(){
FragmentTransaction ft = fm.beginTransaction();
for (Fragment f:fs) {
ft.remove(f);
}
ft.commitAllowingStateLoss();
}
示例11: clearFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
/**
* Metodo statico per eliminare il fragment, quando non sono disponibili parcheggi
*/
public static void clearFragment(MainActivity activity) {
if(activity.getFragmentAttivo() != null) {
// inizializza la fragmentTransaction per l'eliminazione
ParcheggiFragment fragAttivo = activity.getFragmentAttivo();
FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
ft.remove(fragAttivo);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
// elimina il riferimento al fragment in MainActivity
activity.setFragmentAttivo(null);
}
}
示例12: closeFragment
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private void closeFragment() {
FragmentManager fm = getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.remove(fragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE);
ft.commit();
addParticipantContainer.setVisibility(View.GONE);
isFragmentOpen = false;
}
示例13: 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");
}
示例14: showDialog
import android.app.FragmentTransaction; //导入方法依赖的package包/类
private static void showDialog(Activity activity, Class clazz, String tag) {
FragmentManager fm = activity.getFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
Fragment prev = fm.findFragmentByTag(tag);
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
try {
((DialogFragment) clazz.newInstance()).show(ft, tag);
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例15: showChangeLogDialog
import android.app.FragmentTransaction; //导入方法依赖的package包/类
public static void showChangeLogDialog(FragmentManager fragmentManager) {
ChangelogDialog changelogDialog = new ChangelogDialog();
FragmentTransaction ft = fragmentManager.beginTransaction();
Fragment prev = fragmentManager.findFragmentByTag("changelogdemo_dialog");
if (prev != null) {
ft.remove(prev);
}
ft.addToBackStack(null);
changelogDialog.show(ft, "changelogdemo_dialog");
}