androidx.fragment.app.Fragment.getView()方法的使用及代码示例

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

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

Fragment.getView介绍

暂无

代码示例

代码示例来源:origin: proninyaroslav/libretorrent

@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object)
{
  return ((Fragment)object).getView() == view;
}

代码示例来源:origin: AlexMofer/ProjectX

@Override
public boolean isViewFromObject(@NonNull View view, @NonNull Object object) {
  return ((Fragment) object).getView() == view;
}

代码示例来源:origin: AlexMofer/ProjectX

@SuppressLint("CommitTransaction")
@Override
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
  if (mCurTransaction == null) {
    mCurTransaction = mFragmentManager.beginTransaction();
  }
  if (DEBUG) Log.v(TAG, "Detaching item #" + getItemId(position) + ": f=" + object
      + " v=" + ((Fragment) object).getView());
  mCurTransaction.detach((Fragment) object);
}

代码示例来源:origin: google/android-transition-examples

@Override
 public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) {
  // Locate the image view at the primary fragment (the ImageFragment that is currently
  // visible). To locate the fragment, call instantiateItem with the selection position.
  // At this stage, the method will simply return the fragment at the position and will
  // not create a new one.
  Fragment currentFragment = (Fragment) viewPager.getAdapter()
    .instantiateItem(viewPager, MainActivity.currentPosition);
  View view = currentFragment.getView();
  if (view == null) {
   return;
  }
  // Map the first shared element name to the child ImageView.
  sharedElements.put(names.get(0), view.findViewById(R.id.image));
 }
});

代码示例来源:origin: andstatus/andstatus

private View findFragmentViewById(@IdRes int id) {
  Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragmentOne);
  if (fragment != null) {
    View view = fragment.getView();
    if (view != null) {
      return view.findViewById(id);
    }
  }
  return null;
}

代码示例来源:origin: AlexMofer/ProjectX

/**
   * Remove all item
   */
  public void removeAll() {
    if (mCurTransaction == null) {
      mCurTransaction = mFragmentManager.beginTransaction();
    }
    final int count = getCount();
    for (int position = 0; position < count; position++) {
      final long itemId = getItemId(position);
      String name = makeFragmentName(mViewGroupId, itemId);
      Fragment fragment = mFragmentManager.findFragmentByTag(name);
      if (fragment == null)
        continue;
      if (DEBUG) Log.v(TAG, "Detaching item #" + itemId + ": f=" + fragment
          + " v=" + fragment.getView());
      while (mSavedState.size() <= getCount()) {
        mSavedState.add(null);
      }
      mSavedState.set(position, fragment.isAdded()
          ? mFragmentManager.saveFragmentInstanceState(fragment) : null);
      mCurTransaction.remove(fragment);
    }
    mCurTransaction.commitNowAllowingStateLoss();
    mCurTransaction = null;
  }
}

相关文章