티스토리 뷰
Fragment를 Activity의 FrameLayout에 붙이기
소스의 기준은 support v4로 작성함.
그게 맞은것 같음. ㅋ
- Sample Source
SampleFragment sampleFragment = new SampleFragment();
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
// Activity 구조처럼 계속 쌓을경우
fragmentTransaction.add(R.id.framelayout, sampleFragment);
// 기존 Fragment를 대체한다.
fragmentTransaction.replace(R.id.framelayout, sampleFragment);
// 옵션은 두가지이다.
// onSaveInstanceState가 수행되기 전에 호출될 경우에는 이것. 안 그러면 exception이 발생하게 된다.
fragmentTransaction.commit();
// onSaveInstanceState가 수행되고 난 이후에는 아래를 호출한다. 그냥 이것을 사용하는게 편함
fragmentTransaction.commitAllowingStateLoss();
- LifeCycle
Activity_onCreate()
Fragment_onAttach()
Fragment_onCreate()
Fragment_onCreateView()
Fragment_onActivityCreated()
Activity_onStart()
Fragment_onStart()
Activity_onResume()
Fragment_onResume()
Fragment_onPause()
Activity_onPause()
Fragment_onStop()
Activity_onStop()
Fragment_onDestoryView()
Fragment_onDestory()
Fragment_onDetach()
Activity_onDestory()
'Mobile > Android' 카테고리의 다른 글
| [Android]XML로 도형 그리기 (0) | 2015.09.08 |
|---|---|
| [Android]안드로이드 4.4 이상 버전에서 문제되는 사항들. (0) | 2015.09.08 |
| [Android]Canvas에 선을 한번에 그리기 (0) | 2015.09.08 |
| [Android]안드로이드 전화 사용 Intent (0) | 2015.09.08 |
| [Anrdoid]마켓 호출 방법 (0) | 2015.09.08 |
- Total
- Today
- Yesterday
- nodejs
- SWIFT
- CentOS
- Java
- github
- docker
- tomcat
- intellij
- ubuntu
- Gradle
- Spring
- Xcode
- git
- war
- go
- Codable
- Windows
- enum
- ios
- golang
- rxswift
- android
- Python
- php
- Linux
- centos8
- MySQL
- Kotlin
- cocoapods
- windows10
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |