반응형
[Gradle 설정]
1
|
id 'kotlin-android-extensions'
|
cs |
<MainActivity>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package com.example.myapplication
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.MultiAutoCompleteTextView
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
title = "사진 보기"
viewFlipper.flipInterval = 1000
btnStart.setOnClickListener {
viewFlipper.startFlipping()
}
btnStop.setOnClickListener {
viewFlipper.stopFlipping()
}
}
}
|
cs |
<activity_main.xml>
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnStart"
android:text="사진보기 시작"/>
<Button
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnStop"
android:text="사진보기 정지"/>
</LinearLayout>
<ViewFlipper
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/viewFlipper">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/cat"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/dog"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/horse"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/rabbit"/>
</ViewFlipper>
</LinearLayout>
|
cs |
반응형
'안드로이드 프로그래밍 > 코틀린' 카테고리의 다른 글
[코틀린을 활용한 안드로이드 프로그래밍] 8장 직접 풀어보기 8-1 (0) | 2022.05.25 |
---|---|
[코틀린을 활용한 안드로이드 프로그래밍] 6장 직접 풀어보기 6-3 (0) | 2022.05.25 |
[코틀린을 활용한 안드로이드 프로그래밍] 6장 직접 풀어보기 6-1 (0) | 2022.05.22 |
[코틀린을 활용한 안드로이드 프로그래밍] 7장 직접 풀어보기 7-3 (0) | 2022.04.22 |
[코틀린을 활용한 안드로이드 프로그래밍] 10장 연습문제 5번 (0) | 2022.04.15 |