本文整理匯總了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);
}