当前位置: 首页>>代码示例>>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;未经允许,请勿转载。