
지금 여기예요
4
491
동적 프래그먼트
<
fragment
>
요소를 이용하면 가장 간단하게
TempActivity
의
레이아웃에
StopwatchFragment
를 추가할 수 있습니다.
<
fragment
>
요소를 이용하면 프래그먼트 트랜잭션 코드를 구현하지 않고 직접 레이아웃에
프래그먼트를 추가할 수 있기 때문입니다.
다음은
activity
_
temp
.
xml
코드입니다. 여러분 코드를 다음처럼 바꾸세요.
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.hfad.workout.StopwatchFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<xml>
</xml>
app/src/main
activity_
temp.xml
Workout
res
layout
액티비티에 프래그먼트를
추가하는 코드예요.
StopwatchFragment
를 실행할 준비가 되었습니다.
이제 시험 주행을 합시다.
앱 시험 주행
앱을 실행하면
StopwatchFragment
를 포함하는
TempActivity
가
나타납니다. 스톱워 ...