android.app.FragmentManager.getBackStackEntryAt()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中android.app.FragmentManager.getBackStackEntryAt()方法的一些代码示例,展示了FragmentManager.getBackStackEntryAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentManager.getBackStackEntryAt()方法的具体详情如下:
包路径:android.app.FragmentManager
类名称:FragmentManager
方法名:getBackStackEntryAt

FragmentManager.getBackStackEntryAt介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

FragmentManager fm = getFragmentManager();

for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
  Log.i(TAG, "Found fragment: " + fm.getBackStackEntryAt(entry).getId());
}

代码示例来源:origin: stackoverflow.com

private FragmentManager.OnBackStackChangedListener getListener()
{
  FragmentManager.OnBackStackChangedListener result = new FragmentManager.OnBackStackChangedListener()
  {
    public void onBackStackChanged()
    {
      FragmentManager manager = getFragmentManager();

      if (manager != null)
      {
        if(manager.getBackStackEntryCount() >= 1){
          String topOnStack = manager.getBackStackEntryAt(manager.getBackStackEntryCount()-1).getName();
          Log.i("TOP ON BACK STACK",topOnStack);
        }
        }
      }
  };

  return result;
}

代码示例来源:origin: stackoverflow.com

FragmentManager fragmentManager = this.getSupportFragmentManager();  
   String tag = fragmentManager
         .getBackStackEntryAt(
         fragmentManager
         .getBackStackEntryCount() - 1)
         .getName();
      Log.d("This is your Top Fragment name: ", ""+tag);

代码示例来源:origin: stackoverflow.com

FragmentManager frgmanager = getFragmentManager();
 for (int i = 0; i < frgmanager .getBackStackEntryCount(); i++) {
   if (frgmanager .getBackStackEntryAt(i).getName().equalsIgnoreCase(tagname)) {
     return i;
   }
 }

代码示例来源:origin: stackoverflow.com

public static void displayBackStack(FragmentManager fm) {
  int count = fm.getBackStackEntryCount();
  Log.d("Backstack log", "There are " + count + " entries");
  for(int i = 0; i<count; i++) {
    // Display Backstack-entry data like
    String name = fm.getBackStackEntryAt(i).getName();
    Log.d("Backstack log", "entry " + i + ": " + name);
  }
}

代码示例来源:origin: stackoverflow.com

getBackStackEntryCount()
getBackStackEntryAt (int index)
FragmentManager fm = getFragmentManager();
for(int i = 0; i < fm.getBackStackEntryCount(); i++) {
 Log.i(TAG, "Found fragment: " + fm.getBackStackEntryAt(i).getId());
}

代码示例来源:origin: stackoverflow.com

public static boolean isFragmentInBackstack(final FragmentManager fragmentManager, final String fragmentTagName) {
  for (int entry = 0; entry < fragmentManager.getBackStackEntryCount(); entry++) {
    if (fragmentTagName.equals(fragmentManager.getBackStackEntryAt(entry).getName())) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

private int getIndex(String tagname) {
  FragmentManager manager = getFragmentManager();
  for (int i = 0; i < manager.getBackStackEntryCount(); i++) {
    if (manager.getBackStackEntryAt(i).getName().equalsIgnoreCase(tagname)) {
      return i;
    }
  }
  return 0;
}

代码示例来源:origin: stackoverflow.com

FragmentManager manager = getSupportFragmentManager();
int count = manager.getBackStackEntryCount();
if(count>0){
 Fragment  mfragment = manager.getBackStackEntryAt(count-1);
 FragmentTransaction ft = fragmentManager.beginTransaction();
 ft.replace(R.id.content_frame, mFragment);
 ft.commit();
}

代码示例来源:origin: stackoverflow.com

private Fragment getCurrentFragment(){
  FragmentManager fragmentManager = getSupportFragmentManager();
  String fragmentTag = fragmentManager.getBackStackEntryAt(fragmentManager.getBackStackEntryCount() - 1).getName();
  Fragment currentFragment = getSupportFragmentManager()
.findFragmentByTag(fragmentTag);
  return currentFragment;
}

代码示例来源:origin: stackoverflow.com

FragmentManager manager = getSupportFragmentManager();
int count = manager.getBackStackEntryCount();
if(count>0){
 Fragment  mfragment = manager.getBackStackEntryAt(count-1);
 FragmentTransaction ft = fragmentManager.beginTransaction();
 ft.replace(R.id.content_frame, mFragment);
 ft.commit();
}

代码示例来源:origin: stackoverflow.com

FragmentManager fragmentManager = getFragmentManager();
 // Get the last transaction on the stack
 FragmentManager.BackStackEntry backEntry=fragmentManager.getBackStackEntryAt(fragmentManager.getBackStackEntryCount()-1);
 String str = backEntry.getName();
 Fragment fragment = getFragmentManager().findFragmentByTag(str);

代码示例来源:origin: stackoverflow.com

boolean foundMyFragment = false;
   String fragmentBackstackTag = "";
   FragmentManager fm = getSupportFragmentManager();
   for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
     fragmentBackstackTag = fm.getBackStackEntryAt(entry).getName();
     Log.i(TAG, "Found fragment: " + fragmentBackstackTag);
     // check if null, because sometimes fragmentBackstacktag is null
     if (fragmentBackstackTag != null) {
       if (fragmentBackstackTag.equals("fragmentTagYouAreSearching")) {
         foundMyFragment = true;
         // get fragment from backstack
       }
     }
   }

代码示例来源:origin: stackoverflow.com

FragmentManager mgr = getFragmentManager();                 
BackStackEntry be = mgr.getBackStackEntryAt(mgr.getBackStackEntryCount()-1);
String tag be.getName();

System.out.println("tag " + tag);

代码示例来源:origin: stackoverflow.com

@Override
public void onBackPressed() {
  super.onBackPressed();
  FragmentManager fm = getSupportFragmentManager();
  String stackName = null;
  for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
    stackName = fm.getBackStackEntryAt(entry).getName();
    Log.i("BC", "stackEntry" + entry);
  }
  if (stackName == "Fragment1"){
    mDrawerList.setItemChecked(0, true);
  } else if (stackName == "Fragment2") {
    mDrawerList.setItemChecked(1, true);
  }
}

代码示例来源:origin: stackoverflow.com

FragmentManager fm = MainActivity.this.getSupportFragmentManager();
String currentFragmentTag = fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName();

代码示例来源:origin: stackoverflow.com

private boolean loadPreviousFragment() {
  FragmentManager fm = getSupportFragmentManager();
  for(int i = 0; i < fm.getBackStackEntryCount(); i++){
    if(fm.getBackStackEntryAt(i).getName().equals(FRAGMENT_A )){
      fm.getFragments().get(i).onResume();
      return true;
    }

    if(fm.getBackStackEntryAt(i).getName().equals(FRAGMENT_B )){
      fm.getFragments().get(i).onResume();
      return true;
    }
  }
}

代码示例来源:origin: stackoverflow.com

@Override
 public void onBackPressed() {
  FragmentManager fmanger = getSupportFragmentManager();
  if(fmanger.getBackStackEntryCount()>0){
  FragmentManager.BackStackEntry  backEntry=
       fmanger.getBackStackEntryAt(fmanger.getBackStackEntryCount()-1);
    String fragmentName=backEntry.getName();
    if(fragmentName.equals("schedule")){
        // clear all fragment from Activity
        // close Activity 
        this.finish();
     }
  }
 }

代码示例来源:origin: stackoverflow.com

private boolean isFragmentOnTop(Activity parentActivity, final String fragmentName){
   FragmentManager fmManager = parentActivity.getFragmentManager();
   if(fmManager.getBackStackEntryCount() == 0){
     LOG.i("BackStack entry count is 0: " + this);
     return false;
   }
   String fragmentNameOnStackTop = "";
   final FragmentManager.BackStackEntry topEntry = fmManager.getBackStackEntryAt(fmManager.getBackStackEntryCount() -1);
   if(topEntry != null) {
     fragmentNameOnStackTop = topEntry.getName();
   }
   LOG.d("Got fragments name: " + fragmentNameOnStackTop);
   return fragmentNameOnStackTop != null ? fragmentNameOnStackTop.equals(fragmentName) : false;
 }

代码示例来源:origin: com.albedinsky.android/fragments

/**
 * Creates a new instance of FragmentController with the given <var>fragmentManager</var>.
 *
 * @param fragmentManager Fragment manager that will be used to manage fragments.
 * @see #FragmentController(android.app.Activity)
 * @see #FragmentController(android.app.Fragment)
 */
public FragmentController(@NonNull FragmentManager fragmentManager) {
  this.mFragmentManager = fragmentManager;
  mFragmentManager.addOnBackStackChangedListener(new BackStackListener());
  // Check for back stacked fragments.
  final int n = mFragmentManager.getBackStackEntryCount();
  if (n > 0) {
    this.mTopBackStackEntry = mFragmentManager.getBackStackEntryAt(n - 1);
  }
}

相关文章