[코틀린을 활용한 안드로이드 프로그래밍] 10장 연습문제 5번

2022. 4. 15. 13:58·안드로이드 프로그래밍/코틀린
반응형

[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
package com.cookandroid.myapplication
 
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
 
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        title = "연습문제 10-5"
        btnNewActivity.setOnClickListener {
            startActivity(Intent(applicationContext, Second::class.java))
        }
    }
 
}
Colored by Color Scripter
cs

<Second>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.cookandroid.myapplication
 
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.activity_second.*
 
class Second : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)
        title = "Second 액티비티"
        btnReturn.setOnClickListener {
            finish()
        }
        btnNewThirdActivity.setOnClickListener {
            startActivity(Intent(applicationContext, Third::class.java))
 
        }
    }
}
Colored by Color Scripter
cs

<Third>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.cookandroid.myapplication
 
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_second.*
 
class Third : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_third)
        title = "Third 액티비티"
        btnReturn.setOnClickListener {
            finish()
        }
    }
}
Colored by Color Scripter
cs

<activity_main.xml>

1
2
3
4
5
6
7
8
9
10
11
12
13
<?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">
    <Button
        android:id="@+id/btnNewActivity"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="새 화면 열기"/>
 
 
</LinearLayout>
Colored by Color Scripter
cs

<activity_second.xml>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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"
    android:background="#00FF00">
 
    <Button
        android:id="@+id/btnNewThirdActivity"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:text="새 화면 열기"
        android:background="#00F000"/>
 
    <Button
        android:id="@+id/btnReturn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="돌아가기"
        android:background="#00F000"/>
 
</LinearLayout>
Colored by Color Scripter
cs

<activity_third.xml>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?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:background="#0000FF">
 
    <Button
        android:id="@+id/btnReturn"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="돌아가기"
        android:background="#0000F0"/>
 
</LinearLayout>
Colored by Color Scripter
cs

 

반응형
저작자표시 (새창열림)

'안드로이드 프로그래밍 > 코틀린' 카테고리의 다른 글

[코틀린을 활용한 안드로이드 프로그래밍] 6장 직접 풀어보기 6-1  (0) 2022.05.22
[코틀린을 활용한 안드로이드 프로그래밍] 7장 직접 풀어보기 7-3  (0) 2022.04.22
[코틀린을 활용한 안드로이드 프로그래밍] 10장 직접 풀어보기 10-3  (0) 2022.04.15
[코틀린을 활용한 안드로이드 프로그래밍] 4장 직접 풀어보기 4-3  (0) 2022.04.15
[코틀린을 활용한 안드로이드 프로그래밍] 4장 직접 풀어보기 4-4  (0) 2022.04.15
'안드로이드 프로그래밍/코틀린' 카테고리의 다른 글
  • [코틀린을 활용한 안드로이드 프로그래밍] 6장 직접 풀어보기 6-1
  • [코틀린을 활용한 안드로이드 프로그래밍] 7장 직접 풀어보기 7-3
  • [코틀린을 활용한 안드로이드 프로그래밍] 10장 직접 풀어보기 10-3
  • [코틀린을 활용한 안드로이드 프로그래밍] 4장 직접 풀어보기 4-3
슥지니
슥지니
개발 블로그
  • 슥지니
    슥지니의 코딩노트
    슥지니
  • 전체
    오늘
    어제
    • 분류 전체보기 (199)
      • 알고리즘 문제풀이 (158)
        • 백준 (158)
      • 알고리즘 (6)
      • Node.js (2)
        • MongoDB (1)
        • 기타 (1)
      • spring (0)
      • 가상화폐 (1)
        • 바이낸스(Binance) (1)
      • C++ 테트리스 게임 (1)
      • C++ (10)
      • 안드로이드 프로그래밍 (21)
        • 코틀린 (21)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    백트랙킹
    코틀린
    그래프
    알고리즘
    시뮬레이션
    코틀린을 활용한 안드로이드 프로그래밍
    C++
    Kotlin
    콘솔 테트리스 게임
    구현
    백준
    C
    우선순위 큐
    그리디
    dfs
    BFS
    다이나믹 프로그래밍
    자료구조
    콘솔
    dp
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.3
슥지니
[코틀린을 활용한 안드로이드 프로그래밍] 10장 연습문제 5번
상단으로

티스토리툴바