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

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

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

Fragment.onCreate介绍

暂无

代码示例

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

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  lifecycleSubject.onNext(FragmentEvent.CREATE);
}

代码示例来源:origin: cSploit/android

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setHasOptionsMenu(true);
  return inflater.inflate(R.layout.target_layout, container, false);
}

代码示例来源:origin: cSploit/android

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setHasOptionsMenu(true);
  return inflater.inflate(R.layout.actions_layout, container, false);
}

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

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) {
    layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID);
  }
}

代码示例来源:origin: guardianproject/haven

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) {
    layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID);
  }
}

代码示例来源:origin: guardianproject/haven

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  if (getArguments() != null && getArguments().containsKey(ARG_LAYOUT_RES_ID)) {
    layoutResId = getArguments().getInt(ARG_LAYOUT_RES_ID);
  }
}

代码示例来源:origin: guardianproject/haven

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  prefs = new PreferenceManager(getContext());
}

代码示例来源:origin: cSploit/android

@SuppressWarnings("ConstantConditions")
@Override
public void onCreate(Bundle savedInstanceState) {
  SharedPreferences themePrefs = getActivity().getSharedPreferences("THEME", 0);
  if (themePrefs.getBoolean("isDark", false))
    getActivity().setTheme(R.style.PrefsThemeDark);
  else
    getActivity().setTheme(R.style.PrefsTheme);
  super.onCreate(savedInstanceState);
  getActivity().getSupportFragmentManager().beginTransaction()
      .replace(android.R.id.content, new PrefsFrag())
      .commit();
}

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

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
}

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

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  publication = (Publication) getArguments().getSerializable(PUBLICATION);
}

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

@Override public void onCreate(@Nullable Bundle bundle)
{
  super.onCreate(bundle);
  if(mapView != null) mapView.onCreate(bundle);
}

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

@Override public void onCreate(@Nullable Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  Injector.instance.getApplicationComponent().inject(this);
  mapFragment = (MapFragment) getParentFragment();
}

代码示例来源: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: trello/RxLifecycle

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

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

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

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

@Override
public void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  /* Retain this fragment across configuration changes */
  setRetainInstance(true);
}

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

@Override
public void onCreate(@Nullable Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  if (savedInstanceState != null)
    trackers = savedInstanceState.getParcelableArrayList(TAG_TRACKER_LIST);
}

相关文章