本文整理汇总了Java中android.app.FragmentManager.findFragmentByTag方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.findFragmentByTag方法的具体用法?Java FragmentManager.findFragmentByTag怎么用?Java FragmentManager.findFragmentByTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.findFragmentByTag方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.v(TAG, "onCreate: ");
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
FragmentManager fragmentManager = getFragmentManager();
settingsFragment = (SettingsFragment) fragmentManager.findFragmentByTag(TAG);
if (settingsFragment == null) {
settingsFragment = SettingsFragment.newInstance(R.xml.settings_main);
replaceFragment(settingsFragment);
} else {
showFragment(settingsFragment);
}
}
示例2: setupTransaction
import android.app.FragmentManager; //导入方法依赖的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;
}
示例3: showChangeLogDialog
import android.app.FragmentManager; //导入方法依赖的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");
}
示例4: onSaveInstanceState
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onSaveInstanceState(Bundle state) {
if (records.list().isEmpty()) {
state.putBoolean(STATE_CONTENT_VIEW, getErrorView().getVisibility() == View.VISIBLE);
} else {
state.putBoolean(STATE_CONTENT_VIEW, true);
state.putParcelable(Podcast.class.getName(), podcast);
FragmentManager fragmentManager = getFragmentManager();
RecordsDataFragment dataFragment = (RecordsDataFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
if (dataFragment == null) {
dataFragment = new RecordsDataFragment();
fragmentManager.beginTransaction().add(dataFragment, FRAGMENT_TAG).commit();
}
dataFragment.setRecords(records);
dataFragment.setPaginator(paginator);
state.putInt(STATE_FOOTER, adapter.getFooterMode().ordinal());
}
super.onSaveInstanceState(state);
}
示例5: install
import android.app.FragmentManager; //导入方法依赖的package包/类
/**
* Installs BackStack into your app. This must be called in {@link Activity#onCreate(Bundle)}
* @param activity
*/
public static void install(Activity activity){
//Standard retained fragment code. This creates a new fragment if the fragment couldn't be found
FragmentManager fm = activity.getFragmentManager();
RetainedFragment fragment = (RetainedFragment) fm.findFragmentByTag(RetainedFragment.TAG);
if (fragment == null){
fragment = new RetainedFragment();
fm.beginTransaction()
.add(fragment, RetainedFragment.TAG)
.commit();
activity.getApplication().registerActivityLifecycleCallbacks(fragment);
fragment.set(activity, new BackStackManager(activity));
}
backStack = new BackStack(fragment.getBackStackManager(
));
}
示例6: startRecording
import android.app.FragmentManager; //导入方法依赖的package包/类
private void startRecording() {
FragmentManager fragmentManager = getFragmentManager();
ListenerFragment listenerFragment = (ListenerFragment)
fragmentManager.findFragmentByTag(TAG_LISTENER_FRAGMENT);
if (listenerFragment == null) {
listenerFragment = new ListenerFragment();
fragmentManager
.beginTransaction()
.add(listenerFragment, TAG_LISTENER_FRAGMENT)
.commit();
}
}
示例7: onMessageLoaded
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onMessageLoaded() {
Activity currentActivity = CurrentActivityWatchdog.getCurrentActivity();
FragmentManager fragmentManager = currentActivity.getFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag(IamDialog.TAG);
if (fragment == null) {
iamDialog.show(fragmentManager, IamDialog.TAG);
}
}
示例8: cancelDialog
import android.app.FragmentManager; //导入方法依赖的package包/类
private static void cancelDialog(FragmentManager fragmentManager, String tag) {
Fragment fragment = fragmentManager.findFragmentByTag(tag);
if (fragment == null) return;
DialogFragment dialogFragment = (DialogFragment) fragment;
if (dialogFragment.getDialog() == null) return;
dialogFragment.getDialog().cancel();
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:ConfirmSyncDataStateMachine.java
示例9: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String TAG = "ClientCertificateFragment";
FragmentManager fm = getFragmentManager();
ClientCertificateFragment fragment = (ClientCertificateFragment) fm.findFragmentByTag(TAG);
if (fragment == null) {
fragment = new ClientCertificateFragment();
fm.beginTransaction().replace(android.R.id.content, fragment, TAG).commit();
}
}
示例10: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String TAG = "EnabledApplicationsPreferenceFragment";
FragmentManager fm = getFragmentManager();
EnabledApplicationsPreferenceFragment fragment = (EnabledApplicationsPreferenceFragment) fm.findFragmentByTag(TAG);
if (fragment == null) {
fragment = new EnabledApplicationsPreferenceFragment();
fm.beginTransaction().replace(android.R.id.content, fragment, TAG).commit();
}
}
示例11: onCreate
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final String TAG = "CustomNotificationSettingsFragment";
FragmentManager fm = getFragmentManager();
CustomNotificationSettingsFragment fragment = (CustomNotificationSettingsFragment) fm.findFragmentByTag(TAG);
if (fragment == null) {
fragment = new CustomNotificationSettingsFragment();
fm.beginTransaction().replace(android.R.id.content, fragment, TAG).commit();
}
}
示例12: onDestroy
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onDestroy() {
super.onDestroy();
// FragmentTransaction is not allowed if Activity is destroyed
if (!willDestroyActivity() && (!willRecreate())) {
//noinspection ConstantConditions
FragmentManager fm = getActivity().getFragmentManager();
Fragment fragment = fm.findFragmentByTag(getFragmentTag());
if (fragment != null) {
fm.beginTransaction().remove(fragment).commit();
}
}
}
示例13: onBackPressed
import android.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
if (isSearchViewExpanded()) {
hideSearchView();
} else {
final FragmentManager fm = getFragmentManager();
mBackStackEntryPopped = fm.popBackStackImmediate();
final int entryCnt = fm.getBackStackEntryCount();
if (entryCnt > 0) {
final FragmentManager.BackStackEntry entry = fm.getBackStackEntryAt(entryCnt - 1);
final Fragment fragment = fm.findFragmentByTag(entry.getName());
if (fragment instanceof CurrentFeedFragment) {
mBottomNavigationView.setSelectedItemId(R.id.action_view_current_feed);
} else if (fragment instanceof FeedSubscriptionsFragment) {
mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
} else if (fragment instanceof SavedEntriesFragment) {
mBottomNavigationView.setSelectedItemId(R.id.action_view_saved_entries);
} else {
mBackStackEntryPopped = fm.popBackStackImmediate();
mBottomNavigationView.setSelectedItemId(R.id.action_view_feed_subscriptions);
}
mBackStackEntryPopped = false;
} else {
super.onBackPressed();
}
}
}
示例14: attachTo
import android.app.FragmentManager; //导入方法依赖的package包/类
public static void attachTo(Activity activity, Object executionScope, boolean finishAfterDialog, Bundle argumentsForErrorDialog) {
FragmentManager fm = activity.getFragmentManager();
HoneycombManagerFragment fragment = (HoneycombManagerFragment) fm.findFragmentByTag(ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER);
if (fragment == null) {
fragment = new HoneycombManagerFragment();
fm.beginTransaction().add(fragment, ErrorDialogManager.TAG_ERROR_DIALOG_MANAGER).commit();
fm.executePendingTransactions();
}
fragment.finishAfterDialog = finishAfterDialog;
fragment.argumentsForErrorDialog = argumentsForErrorDialog;
fragment.executionScope = executionScope;
}
示例15: findOrNull
import android.app.FragmentManager; //导入方法依赖的package包/类
public static <T> RetainFragment<T> findOrNull(FragmentManager fm, String tag) {
// noinspection unchecked, we know this is the the right type
return (RetainFragment<T>) fm.findFragmentByTag(tag);
}