티스토리 뷰
Ref : https://www.youtube.com/watch?v=uRyvNKRkwbs&t=22211s
주안점
1. Calendar 사용법
2. clickDatePicker의 매개변수로 view 설정
3. dateSetListener의 날짜들 != 이전 선언한 날짜 변수들
4. simpleDateFormat
binding.btnDatePicker.setOnClickListener{view ->
clickDatePicker(view)
}
}
fun clickDatePicker(view: View){
val myCalendar = Calendar.getInstance()
val year = myCalendar.get(Calendar.YEAR)
val month = myCalendar.get(Calendar.MONTH)
val day = myCalendar.get(Calendar.DAY_OF_MONTH)
DatePickerDialog(
this,
DatePickerDialog.OnDateSetListener {
view, selYear, selMonth, selDayOfMonth ->
val selectedDate = "$selDayOfMonth/${selMonth+1}/${selYear}"
binding.tvSelectedDate.setText(selectedDate)
val sdf = SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH)
val theDate = sdf.parse(selectedDate)
val millionSeconds = Calendar.getInstance().timeInMillis - theDate.time
binding.tvSelectedDateInMinutes.setText(
java.util.concurrent.TimeUnit.MILLISECONDS.toMinutes(millionSeconds).toString()
)
}
,year
, month
, day).show()
}
}
'App > Android Native' 카테고리의 다른 글
카메라 기능 구현 w cameraX in kotlin (0) | 2021.09.30 |
---|---|
Practice - mini project w kotlin - Calculator (0) | 2021.09.27 |
KOTLIN BASIC IV (0) | 2021.09.24 |
KOTLIN BASIC III (OOP) (0) | 2021.09.23 |
KOTLIN BASIC II (0) | 2021.09.22 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- querydslQclass
- mvvm
- AndroidWirelessDebug
- Laravel
- android_app_links
- KotlinFlow
- WirelessDebug
- phplaravel
- unsplashAPI
- Kotlin
- flutter_android_app_links
- android_app_links_domain
- querydsl5.0.0jakarta
- RunAFlutterProjectIniPhoneFromVSCode
- MultipleFirebaseEnvironments
- querydslKotlinError
- Android
- futter_api
- flutter_secure_storage_issue_iOS
- flutter
- dagger-hilt
- android_domain
- FirebaseConfigurationForMultipleBuildTypes
- retrofit_toJson()_error
- FlutterWirelessDebuginAOS
- android_app_link_domain_works_with_adb_but_not_works_with_browser
- flutter_storage_not_working_for_the_first_time
- retrofit_generator_conflicts_with_freezed
- retrofit_generator
- laravel9
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함