當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentManager.findFragmentByTag方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:pedromassango,項目名稱:Programmers,代碼行數:19,代碼來源:SettingsActivity.java

示例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;
}
 
開發者ID:linklux,項目名稱:android-schedules,代碼行數:19,代碼來源:BaseDialogFragment.java

示例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");
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:11,代碼來源:ChangelogDialog.java

示例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);
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:21,代碼來源:RecordsActivity.java

示例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(
    ));
}
 
開發者ID:kevinwang5658,項目名稱:backstack,代碼行數:22,代碼來源:BackStack.java

示例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();
    }
}
 
開發者ID:gstraube,項目名稱:cythara,代碼行數:14,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:emartech,項目名稱:android-mobile-engage-sdk,代碼行數:10,代碼來源:DefaultMessageLoadedListener.java

示例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();
    }
}
 
開發者ID:rootkiwi,項目名稱:an2linuxclient,代碼行數:15,代碼來源:ClientCertificateActivity.java

示例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();
    }
}
 
開發者ID:rootkiwi,項目名稱:an2linuxclient,代碼行數:12,代碼來源:EnabledApplicationsActivity.java

示例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();
    }
}
 
開發者ID:rootkiwi,項目名稱:an2linuxclient,代碼行數:12,代碼來源:CustomNotificationSettingsActivity.java

示例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();
    }
  }
}
 
開發者ID:seven332,項目名稱:Stage,代碼行數:16,代碼來源:FragmentScene.java

示例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();
        }
    }
}
 
開發者ID:Applications-Development,項目名稱:SimpleRssReader,代碼行數:31,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:13,代碼來源:ErrorDialogManager.java

示例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);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:5,代碼來源:RetainFragment.java


注:本文中的android.app.FragmentManager.findFragmentByTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。