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


Java FragmentManager類代碼示例

本文整理匯總了Java中android.app.FragmentManager的典型用法代碼示例。如果您正苦於以下問題:Java FragmentManager類的具體用法?Java FragmentManager怎麽用?Java FragmentManager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FragmentManager類屬於android.app包,在下文中一共展示了FragmentManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: goBack

import android.app.FragmentManager; //導入依賴的package包/類
@Override
public void goBack() {
    FragmentManager fragmentManager = getFragmentManager();
    if (mDisplayMode == DisplayMode.MESSAGE_VIEW) {
        showMessageList();
    } else if (fragmentManager.getBackStackEntryCount() > 0) {
        fragmentManager.popBackStack();
    } else if (mMessageListFragment.isManualSearch()) {
        finish();
    } else if (!mSingleFolderMode) {
        onAccounts();
    } else {
        onShowFolderList();
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:16,代碼來源:MessageList.java

示例2: showDetails

import android.app.FragmentManager; //導入依賴的package包/類
/**
 * Hide list, show details and instruct the details view to show the selected book.
 */
@Override
public void showDetails(Book book, Drawable thumb) {
  final FragmentManager fragmentManager = getFragmentManager();
  FragmentTransaction ft = fragmentManager.beginTransaction();
  BookDetailsFragment details = (BookDetailsFragment) fragmentManager.findFragmentById(R.id.book_details);

  if (book != null) {
    // If null passed, we only configure fragment transaction here.
    details.showDetails(book, thumb);
  }

  ft.show(details);
  ft.hide(fragmentManager.findFragmentById(R.id.book_list));
  ft.addToBackStack("details"); // Use the back button to return to the search list view.

  ft.commit();
}
 
開發者ID:andviane,項目名稱:google-books-android-viewer,代碼行數:21,代碼來源:BookListActivity.java

示例3: onAttachView

import android.app.FragmentManager; //導入依賴的package包/類
@Override
protected void onAttachView(@NonNull View view) {
  super.onAttachView(view);

  //noinspection ConstantConditions
  FragmentManager fm = getActivity().getFragmentManager();
  Fragment fragment = fm.findFragmentByTag(getFragmentTag());

  if (fragment == null) {
    fragment = onCreateFragment();
    fm.beginTransaction().add(getContainerId(), fragment, getFragmentTag()).commit();
  } else {
    FragmentTransaction transaction = fm.beginTransaction();
    // transaction.attach() may not work if the the fragment isn't detached
    if (!fragment.isDetached()) {
      transaction.detach(fragment);
    }
    transaction.attach(fragment).commit();
  }
}
 
開發者ID:seven332,項目名稱:Stage,代碼行數:21,代碼來源:FragmentScene.java

示例4: show

import android.app.FragmentManager; //導入依賴的package包/類
public void show(FragmentManager manager, String tag) {
    if (!mDismissed) {
        return;
    }
    mDismissed = false;
    FragmentTransaction ft = manager.beginTransaction();
    ft.add(this, tag);
    ft.addToBackStack("actionSheet");
    ft.commit();
}
 
開發者ID:hh-in-zhuzhou,項目名稱:ShangHanLun,代碼行數:11,代碼來源:ActionSheet.java

示例5: initializeFragments

import android.app.FragmentManager; //導入依賴的package包/類
/**
 * Create fragment instances if necessary.
 *
 * @see #findFragments()
 */
private void initializeFragments() {
    FragmentManager fragmentManager = getFragmentManager();
    fragmentManager.addOnBackStackChangedListener(this);

    boolean hasMessageListFragment = (mMessageListFragment != null);

    if (!hasMessageListFragment) {
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mMessageListFragment = MessageListFragment.newInstance(mSearch, false,
                (QMail.isThreadedViewEnabled() && !mNoThreading));
        ft.add(R.id.message_list_container, mMessageListFragment);
        ft.commit();
    }

    // Check if the fragment wasn't restarted and has a MessageReference in the arguments. If
    // so, open the referenced message.
    if (!hasMessageListFragment && mMessageViewFragment == null &&
            mMessageReference != null) {
        openMessage(mMessageReference);
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:27,代碼來源:MessageList.java

示例6: openFragment

import android.app.FragmentManager; //導入依賴的package包/類
private void openFragment(Fragment fragment) {
    this.fragment = fragment;
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(R.id.addParticipantContainer, fragment);
    fragmentTransaction.commit();
    addParticipantContainer.setVisibility(View.VISIBLE);
    isFragmentOpen = true;
}
 
開發者ID:StringflowServer,項目名稱:Beach-Android,代碼行數:10,代碼來源:GroupDetailsActivity.java

示例7: 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

示例8: addFragmentToActivity

import android.app.FragmentManager; //導入依賴的package包/類
/**
 * The {@code fragment} is added to the container view with id {@code frameId}. The operation is
 * performed by the {@code fragmentManager}.
 */
public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager,
                                         @NonNull Fragment fragment, int frameId) {
    checkNotNull(fragmentManager);
    checkNotNull(fragment);
    FragmentTransaction transaction = fragmentManager.beginTransaction();
    transaction.add(frameId, fragment);
    transaction.commit();
}
 
開發者ID:gengqifu,項目名稱:361Camera,代碼行數:13,代碼來源:ActivityUtils.java

示例9: findOrCreateFragment

import android.app.FragmentManager; //導入依賴的package包/類
/**
 * Retrieves the fragment with the given tag. If not exists then a new fragment will be created.
 *
 * @param fragmentManager The fragment manager used to find fragment.
 * @param tag             Fragment tag.
 * @return The retrieved retained fragment or a its new instance.
 */
@NonNull
public static Fragment findOrCreateFragment(@NonNull final FragmentManager fragmentManager, @NonNull final String tag) {
    checkNotNull(fragmentManager, "fragmentManager must not be null!");
    checkNotNull(tag, "tag must not be null!");
    checkArgument(!tag.isEmpty(), "tag string must not be empty!");

    Fragment fragment = fragmentManager.findFragmentByTag(tag);

    if (fragment == null) {
        fragment = DiffRequestManagerHolderFragment.newInstance(DiffRequestManagerHolder.create());
        addFragmentToActivity(fragmentManager, fragment, tag);
    }

    return fragment;
}
 
開發者ID:storix,項目名稱:RxDiffUtil,代碼行數:23,代碼來源:ActivityUtils.java

示例10: DroidSpeech

import android.app.FragmentManager; //導入依賴的package包/類
/**
 * Droid Speech Constructor
 *
 * @param context The application context instance
 *
 * @param fragmentManager The fragment manager instance (Pass this "null" if Droid Speech doesn't
 *                        want to handle permissions)
 */
public DroidSpeech(Context context, FragmentManager fragmentManager)
{
    this.context = context;
    dsProperties.listeningMsg = context.getResources().getString(R.string.ds_listening);

    if(fragmentManager != null)
    {
        // Initializing the Non-UI droid speech fragment and beginning transaction
        droidSpeechPermissions = new DroidSpeechPermissions();
        fragmentManager.beginTransaction().add(droidSpeechPermissions, TAG).commit();
    }

    // Initializing the recognition progress view
    initRecognitionProgressView();

    // Starting the language receiver to get the device language details
    startLanguageReceiver();
}
 
開發者ID:vikramezhil,項目名稱:DroidSpeech,代碼行數:27,代碼來源:DroidSpeech.java

示例11: show

import android.app.FragmentManager; //導入依賴的package包/類
private static void show(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query, int anim) {
	final Bundle args = new Bundle();
	args.putInt(EXTRA_TYPE, type);
	args.putParcelable(EXTRA_ROOT, root);
	args.putParcelable(EXTRA_DOC, doc);
	args.putString(EXTRA_QUERY, query);

	final FragmentTransaction ft = fm.beginTransaction();
	switch (anim) {
	case ANIM_SIDE:
		args.putBoolean(EXTRA_IGNORE_STATE, true);
		break;
	case ANIM_DOWN:
		ft.setCustomAnimations(R.animator.dir_down, R.animator.dir_frozen);
		break;
	case ANIM_UP:
		ft.setCustomAnimations(R.animator.dir_frozen, R.animator.dir_up);
		break;
	}

	final DirectoryFragment fragment = new DirectoryFragment();
	fragment.setArguments(args);

	ft.replace(R.id.container_directory, fragment);
	ft.commitAllowingStateLoss();
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:27,代碼來源:DirectoryFragment.java

示例12: OnComplete

import android.app.FragmentManager; //導入依賴的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);
}
 
開發者ID:CMPUT301W17T08,項目名稱:Moodr,代碼行數:15,代碼來源:MyProfileActivity.java

示例13: onCreate

import android.app.FragmentManager; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);


    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    FragmentManager fragmentManager = getFragmentManager();

    fragmentManager.beginTransaction()
            .replace(R.id.content_frame
                    , new HomeFragment())
            .commit();
}
 
開發者ID:curbmap,項目名稱:curbmap-android,代碼行數:25,代碼來源:MainActivity.java

示例14: showFragment

import android.app.FragmentManager; //導入依賴的package包/類
private void showFragment(String name) {
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    for (Fragment f : fragments.values()) {
        fragmentTransaction.hide(f);
    }

    if (fragments.containsKey(name)) {
        fragmentTransaction.show(fragments.get(name));
        currentFragment = name;
    }

    fragmentTransaction.commit();
}
 
開發者ID:konachan700,項目名稱:SSHFileManager,代碼行數:16,代碼來源:MainActivity.java

示例15: onDocumentPicked

import android.app.FragmentManager; //導入依賴的package包/類
@Override
public void onDocumentPicked(DocumentInfo doc) {
    final FragmentManager fm = getFragmentManager();
    if (doc.isDirectory()) {
        mState.stack.push(doc);
        mState.stackTouched = true;
        onCurrentDirectoryChanged(ANIM_DOWN);
    } else {
        // Fall back to viewing
        final Intent view = new Intent(Intent.ACTION_VIEW);
        view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        view.setData(doc.derivedUri);
        try {
            startActivity(view);
        } catch (ActivityNotFoundException ex2) {
            Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show();
        }
    }
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:20,代碼來源:StandaloneActivity.java


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