16. <LinearLayout>
<include layout=”...>
<include layout=”...>
</LinearLayout>
중첩된 요소를 관리할 방법이 없었습니다.
<LinearLayout>
<include layout=”...>
<include layout=”...>
</LinearLayout>
17. Activity를 중첩하면 어때?
ActivityGroup (eg. TabActivity)는 Activity를 포함시킬 수
있었습니다. (현재는 deprecated)
View 모델로는 상황에 따른 관리가 어렵다.
Activity는 중첩을 고려하지 않아 여러 문제가 존재.
24. <FrameLayout xmlns:android="http://schemas.android.com/apk/
res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
class="com.example.android.apis.app.FragmentLayout
$TitlesFragment"
android:id="@+id/titles"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
fragment에 class를 정적으로 넣어 생성하는 방법
25. DetailsFragment details = (DetailsFragment)
getFragmentManager().findFragmentById(R.id.details);
if (details == null || details.getShownIndex() != index) {
// Make new fragment to show this selection.
details = DetailsFragment.newInstance(index);
// Execute a transaction, replacing any existing
// fragment with this one inside the frame.
FragmentTransaction ft
= getFragmentManager().beginTransaction();
ft.replace(R.id.details, details);
ft.setTransition(
FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();
}
fragment를 동적으로 생성하거나 교체하는 방법
한번에 여러 fragment가 교체될 수 있고 백스택에 의해
관리됨. 그렇기 때문에 트랜잭션을 만들어야 함.
add와 replace를 주로 사용.