아래와 같이 생긴 부분 plus버튼을 누르면 쭉쭉 올라가는 부분입니다.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val progress = findViewById<ProgressBar>(R.id.progress)
val plus = findViewById<Button>(R.id.plus)
var count = 0
plus.setOnClickListener {
count += 10
progress.progress = count
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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"
android:orientation="vertical">
<ProgressBar
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:layout_margin="30dp"/>
<Button
android:id="@+id/plus"
android:layout_margin="10dp"
android:text="+"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
'Android(Kotlin)' 카테고리의 다른 글
Andorid ImageView to Bitmap (0) | 2023.02.06 |
---|---|
ROOM + Coroutine Flow - 5 (Flow) (0) | 2023.01.28 |
Threading models in Coroutines and Android SQLite API (0) | 2023.01.19 |
local.properties (0) | 2023.01.17 |
Unix Time to SimpleDataFormat (0) | 2023.01.09 |