반응형
ProgressDialog
설명
- 작업중임을 표시하는 다이얼로그
- 사용자가 애플리케이션을 조작할 수 없도록 막는 기능을 수행
- 안드로이드 8.0 이상부터는 사용을 권장하지 않는다.
코드
res/layout/activity_main.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="click" />
</LinearLayout>
MainActivity
class MainActivity : AppCompatActivity() {
var progressDialog: ProgressDialog? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.button)
button.setOnClickListener {
progressDialog = ProgressDialog.show(this, "타이틀입니다.", "메시지입니다.")
progressDialog?.show()
val handler = Handler()
val thread = Runnable {
progressDialog?.cancel()
}
handler.postDelayed(thread, 5000)
}
}
}
참고
반응형
'Development > Android' 카테고리의 다른 글
[Android] DatePicker (0) | 2021.02.09 |
---|---|
[Android] ListDialog (0) | 2021.02.09 |
[Android] AlertDialog (0) | 2021.02.09 |
[Android] ActionBar (0) | 2021.02.09 |
[Android] PopupMenu (0) | 2021.02.09 |