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

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

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

Fragment.onViewCreated介绍

暂无

代码示例

代码示例来源:origin: tyzlmjj/PagerBottomTabStrip

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  mTvText = view.findViewById(R.id.tv_text);
}

代码示例来源:origin: trello/RxLifecycle

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);
}

代码示例来源:origin: mikepenz/AboutLibraries

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  libsFragmentCompat.onViewCreated(view, savedInstanceState);
}

代码示例来源:origin: niorgai/StatusBarCompat

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  initCheckBox();
}

代码示例来源:origin: ybq/Android-SpinKit

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
  GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 4);
  layoutManager.setOrientation(RecyclerView.VERTICAL);
  recyclerView.setLayoutManager(layoutManager);
  recyclerView.setAdapter(new RecyclerView.Adapter<Holder>() {
    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
      @SuppressLint("InflateParams") View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list, null);
      return new Holder(view);
    }
    @Override
    public void onBindViewHolder(Holder holder, int position) {
      holder.bind(position);
    }
    @Override
    public int getItemCount() {
      return Style.values().length;
    }
  });
}

代码示例来源:origin: ArthurHub/Android-Image-Cropper

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
 super.onViewCreated(view, savedInstanceState);
 mCropImageView = view.findViewById(R.id.cropImageView);
 mCropImageView.setOnSetImageUriCompleteListener(this);
 mCropImageView.setOnCropImageCompleteListener(this);
 updateCurrentCropViewOptions();
 if (savedInstanceState == null) {
  if (mDemoPreset == CropDemoPreset.SCALE_CENTER_INSIDE) {
   mCropImageView.setImageResource(R.drawable.cat_small);
  } else {
   mCropImageView.setImageResource(R.drawable.cat);
  }
 }
}

代码示例来源:origin: ybq/Android-SpinKit

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  //ProgressBar
  ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress);
  DoubleBounce doubleBounce = new DoubleBounce();
  doubleBounce.setBounds(0, 0, 100, 100);
  doubleBounce.setColor(colors[7]);
  progressBar.setIndeterminateDrawable(doubleBounce);
  //Button
  Button button = (Button) view.findViewById(R.id.button);
  mWaveDrawable = new Wave();
  mWaveDrawable.setBounds(0, 0, 100, 100);
  //noinspection deprecation
  mWaveDrawable.setColor(getResources().getColor(R.color.colorAccent));
  button.setCompoundDrawables(mWaveDrawable, null, null, null);
  //TextView
  TextView textView = (TextView) view.findViewById(R.id.text);
  mCircleDrawable = new Circle();
  mCircleDrawable.setBounds(0, 0, 100, 100);
  mCircleDrawable.setColor(Color.WHITE);
  textView.setCompoundDrawables(null, null, mCircleDrawable, null);
  textView.setBackgroundColor(colors[2]);
  //ImageView
  ImageView imageView = (ImageView) view.findViewById(R.id.image);
  mChasingDotsDrawable = new ChasingDots();
  mChasingDotsDrawable.setColor(Color.WHITE);
  imageView.setImageDrawable(mChasingDotsDrawable);
  imageView.setBackgroundColor(colors[0]);
}

代码示例来源:origin: mikepenz/Android-Iconics

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  // Init and Setup RecyclerView
  RecyclerView recyclerView = view.findViewById(R.id.list);
  recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
  recyclerView.addItemDecoration(new SpaceItemDecoration());
  //animator not yet working
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  mAdapter = new FastItemAdapter<>();
  configAdapter();
  recyclerView.setAdapter(mAdapter);
  if (getArguments() != null) {
    String fontName = getArguments().getString(FONT_NAME);
    for (ITypeface iTypeface : Iconics.getRegisteredFonts(getActivity())) {
      if (iTypeface.getFontName().equalsIgnoreCase(fontName)) {
        if (iTypeface.getIcons() != null) {
          for (String icon : iTypeface.getIcons()) {
            mIcons.add(new IconItem(icon));
          }
          mAdapter.set(mIcons);
          break;
        }
      }
    }
  }
  //filter if a search param was provided
  onSearch(mSearch);
}

代码示例来源:origin: FolioReader/FolioReader-Android

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  mTableOfContentsRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view_menu);
  errorView = (TextView) view.findViewById(R.id.tv_error);
  configRecyclerViews();
  initAdapter();
}

代码示例来源:origin: trello/RxLifecycle

private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
  Fragment fragment = (Fragment) provider;
  startFragment(fragment);
  TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();
  fragment.onAttach(null);
  fragment.onCreate(null);
  fragment.onViewCreated(null, null);
  fragment.onStart();
  fragment.onResume();
  fragment.onPause();
  fragment.onStop();
  fragment.onDestroyView();
  fragment.onDestroy();
  fragment.onDetach();
  testObserver.assertValues(
    FragmentEvent.ATTACH,
    FragmentEvent.CREATE,
    FragmentEvent.CREATE_VIEW,
    FragmentEvent.START,
    FragmentEvent.RESUME,
    FragmentEvent.PAUSE,
    FragmentEvent.STOP,
    FragmentEvent.DESTROY_VIEW,
    FragmentEvent.DESTROY,
    FragmentEvent.DETACH
  );
}

代码示例来源:origin: trello/RxLifecycle

private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
  Fragment fragment = (Fragment) provider;
  startFragment(fragment);
  TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();
  fragment.onAttach(null);
  fragment.onCreate(null);
  fragment.onViewCreated(null, null);
  fragment.onStart();
  fragment.onResume();
  fragment.onPause();
  fragment.onStop();
  fragment.onDestroyView();
  fragment.onDestroy();
  fragment.onDetach();
  testObserver.assertValues(
    FragmentEvent.ATTACH,
    FragmentEvent.CREATE,
    FragmentEvent.CREATE_VIEW,
    FragmentEvent.START,
    FragmentEvent.RESUME,
    FragmentEvent.PAUSE,
    FragmentEvent.STOP,
    FragmentEvent.DESTROY_VIEW,
    FragmentEvent.DESTROY,
    FragmentEvent.DETACH
  );
}

代码示例来源:origin: trello/RxLifecycle

private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {
  Fragment fragment = (Fragment) provider;
  startFragment(fragment);
  TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();
  fragment.onAttach(null);
  testObserver.assertNotComplete();
  fragment.onCreate(null);
  testObserver.assertNotComplete();
  fragment.onViewCreated(null, null);
  testObserver.assertNotComplete();
  fragment.onStart();
  testObserver.assertNotComplete();
  fragment.onResume();
  testObserver.assertNotComplete();
  fragment.onPause();
  testObserver.assertNotComplete();
  fragment.onStop();
  testObserver.assertComplete();
}

代码示例来源:origin: trello/RxLifecycle

private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {
  Fragment fragment = (Fragment) provider;
  startFragment(fragment);
  TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();
  fragment.onAttach(null);
  testObserver.assertNotComplete();
  fragment.onCreate(null);
  testObserver.assertNotComplete();
  fragment.onViewCreated(null, null);
  testObserver.assertNotComplete();
  fragment.onStart();
  testObserver.assertNotComplete();
  fragment.onResume();
  testObserver.assertNotComplete();
  fragment.onPause();
  testObserver.assertNotComplete();
  fragment.onStop();
  testObserver.assertComplete();
}

代码示例来源:origin: westnordost/StreetComplete

@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
{
  super.onViewCreated(view, savedInstanceState);
  ViewUtils.postOnLayout(view, () ->
  {
    if(!isShowingControls)
    {
      hideAll(leftSide, -1);
      hideAll(rightSide, +1);
    }
  });
  mapFragment.onMapControlsCreated(this);
}

代码示例来源:origin: westnordost/StreetComplete

@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState)
{
  super.onViewCreated(view, savedInstanceState);
  if(savedInstanceState == null)
  {
    getChildFragmentManager().beginTransaction().add(R.id.controls_fragment, new MapControlsFragment()).commit();
  }
}

代码示例来源:origin: westnordost/StreetComplete

@Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState)
  super.onViewCreated(view, savedInstanceState);

代码示例来源:origin: FolioReader/FolioReader-Android

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  RecyclerView highlightsView = (RecyclerView) mRootView.findViewById(R.id.rv_highlights);
  Config config = AppUtil.getSavedConfig(getActivity());
  mBookId = getArguments().getString(FolioReader.EXTRA_BOOK_ID);
  if (config.isNightMode()) {
    mRootView.findViewById(R.id.rv_highlights).
        setBackgroundColor(ContextCompat.getColor(getActivity(),
            R.color.black));
  }
  highlightsView.setLayoutManager(new LinearLayoutManager(getActivity()));
  highlightsView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
  adapter = new HighlightAdapter(getActivity(), HighLightTable.getAllHighlights(mBookId), this, config);
  highlightsView.setAdapter(adapter);
}

代码示例来源:origin: trello/RxLifecycle

TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onViewCreated(null, null);
attachObserver.assertNotComplete();
createObserver.assertNotComplete();

代码示例来源:origin: trello/RxLifecycle

TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();
fragment.onViewCreated(null, null);
attachObserver.assertNotComplete();
createObserver.assertNotComplete();

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

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
 super.onViewCreated(view, savedInstanceState);
 scrollToPosition();
}

相关文章