Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- JavaScript
- Express
- Android
- Python
- IntelliJ
- es6
- 보조정렬
- mapreduce
- vaadin
- NPM
- SSL
- Eclipse
- Kotlin
- plugin
- table
- R
- Java
- SPC
- react
- GIT
- hadoop
- MSSQL
- window
- Spring
- SQL
- Sqoop
- 공정능력
- mybatis
- xPlatform
- tomcat
Archives
- Today
- Total
DBILITY
precaution when android fragment programmatic creation 본문
반응형
RecyclerView의 position이 화면 회전시 처음으로 돌아가버려서 테스트 함
Activity > FrameLayout > Fragment > RecyclerView 상태에서
Activity onCreate시 savedInstanceState가 null일때만 Fragment를 Programmatic 생성해야함
ListAdapter에 onAttachedToRecyclerView override해서 확인해보니 두번 실행되어 발견함...역시..초보는 어려워
Activity > FragmentContainerView일때는 별도 생성을 안하니 이상이 없었음.
Activity > ViewPager2 > Fragment > RecyclerView인 경우는 어떻게 해야하지? Fragment가 사라짐
ViewPager2의 adapter를보니 RecyclerView기반이라는데 그것때문인가
Set a new adapter to provide page views on demand.
If you're planning to use Fragments as pages, implement FragmentStateAdapter. If your pages are Views, implement RecyclerView.Adapter as usual.
If your pages contain LayoutTransitions, then those LayoutTransitions must have animateParentHierarchy set to false. Note that if you have a ViewGroup with animateLayoutChanges="true" in your layout xml file, a LayoutTransition is added automatically to that ViewGroup. You will need to manually call getLayoutTransition().setAnimateParentHierarchy(false) on that ViewGroup after you inflated the xml layout, like this:
View view = layoutInflater.inflate(R.layout.page, parent, false);
ViewGroup viewGroup = view.findViewById(R.id.animated_viewgroup);
viewGroup.getLayoutTransition().setAnimateParentHierarchy(false);
Params:
adapter – The adapter to use, or null to remove the current adapter
See Also:
androidx.viewpager2.adapter.FragmentStateAdapter, RecyclerView.setAdapter(RecyclerView.Adapter)
savedInstanceState 체크를 제외하니 됨. lifecycle을 확인해봐야 겠다. 우선은 된다.
반응형
'android' 카테고리의 다른 글
공휴일 api 제공 site (0) | 2024.04.01 |
---|---|
android version catalog (0) | 2024.03.29 |
open api server address (0) | 2024.03.15 |
android studio Project Errors...Unresolved reference: ..... (0) | 2024.03.13 |
안드로이드 dp, dip, sp, sip, dpi , px 등 (0) | 2024.03.11 |
Comments