티스토리 뷰
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
|
package com.example.application
import android.os.Bundle
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
class Calc {
var num = 0
}
val calc = Calc()
plus.setOnClickListener{
val number = etext.text.toString()
calc.num = Integer.parseInt(number)
etext.setText("")
Toast.makeText(this,
"입력된 숫자 " + calc.num+"",Toast.LENGTH_LONG).show()
}
equal.setOnClickListener{
var num1 = calc.num
var num2 = Integer.parseInt(etext.text.toString())
etext.setText((num1 + num2).toString())
}
}
}
|
cs |
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/etext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="150dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/plus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:text="+"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/etext" />
<Button
android:id="@+id/minus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
android:text="-"
app:layout_constraintStart_toStartOf="@+id/plus"
app:layout_constraintTop_toBottomOf="@+id/plus" />
<Button
android:id="@+id/multiply"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="28dp"
android:text="*"
app:layout_constraintStart_toStartOf="@+id/minus"
app:layout_constraintTop_toBottomOf="@+id/minus" />
<Button
android:id="@+id/divid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:text="/"
app:layout_constraintStart_toStartOf="@+id/multiply"
app:layout_constraintTop_toBottomOf="@+id/multiply" />
<Button
android:id="@+id/equal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:layout_marginTop="26dp"
android:text="="
app:layout_constraintStart_toStartOf="@+id/divid"
app:layout_constraintTop_toBottomOf="@+id/divid" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="55dp"
android:layout_marginTop="34dp"
android:layout_marginEnd="55dp"
android:gravity="center"
android:textSize="50dp"
android:text="계 산 기"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
|
cs |
'8. 모바일' 카테고리의 다른 글
[Madrid] FBV (Function based view) 로 connection 체크하기 (0) | 2021.10.01 |
---|---|
장고/2021-12-/마드리드/ Django 와 React 연결하기 (0) | 2021.09.30 |
[Madrid] ModuleNotFoundError: No module named 'admin.sorting'; 'admin' is not a package 에러 해결방법 (0) | 2021.09.23 |
[Madrid] 파이참에서 디폴트가 power shell 에서 cmd 로 변경하기 (0) | 2021.09.17 |
안드로이드/코틀린/2020-05-03/ Gradle for Kotlin: build.gradle (0) | 2020.05.03 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- terms
- Mlearn
- mariadb
- nodejs
- vscode
- AWS
- Algorithm
- Eclipse
- COLAB
- FLASK
- intellij
- Oracle
- Django
- database
- SQLAlchemy
- docker
- SpringBoot
- JUnit
- springMVC
- tensorflow
- React
- KAFKA
- ERD
- JPA
- maven
- Mongo
- Git
- jQuery
- Python
- Java
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함