FragmentStatePagerAdapter構築メソッドでは、新しいパラメーターの動作が追加されています。

AndroidStudioでの説明は次のようになります。

androidx.fragment.app.FragmentStatePagerAdapter public FragmentStatePagerAdapter(@NonNull androidx.fragment.app.FragmentManager fm,  int behavior)

Constructor for FragmentStatePagerAdapter. If BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT is passed in, then only the current Fragment is in the Lifecycle.State.RESUMED state, while all other fragments are capped at Lifecycle.State.STARTED. If BEHAVIOR_SET_USER_VISIBLE_HINT is passed, all fragments are in the Lifecycle.State.RESUMED state and there will be callbacks to Fragment.setUserVisibleHint(boolean).

Params:
fm – fragment manager that will interact with this adapter
behavior – determines if only current fragments are in a resumed state

Fragmentの利点は、現在のページの前のページと次のページのみをロードしてリソースを節約できることです。
現在、最適化が行われているようです。上記の段落の一般的な意味は、intの動作がに設定されている場合です。 BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENTでは、現在のページのみが読み込まれます。これは、遅延読み込みと呼ばれる特定の状態になりますか?BEHAVIOR_SET_USER_VISIBLE_HINTに設定されている場合は、すべて読み込まれます〜

ねえ、それが本当かどうかはわかりません、それは何もないようです

おすすめ

転載: blog.csdn.net/qq_41446977/article/details/112846129