本文整理汇总了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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
}
}