구조는 다이얼 시간 선택기와 기본적으로 동일하며, TimePicker 대신 TimeInput를 사용하는 것이 주요 차이점입니다.
timePickerState의 is24Hour 매개변수가 true로 명시적으로 설정됩니다.
기본적으로 이 값은 false입니다.
이 구현은 다음과 같이 표시됩니다.
그림 3. 입력 시간 선택기입니다.
상태 사용
사용자가 시간 선택 도구에서 선택한 시간을 사용하려면 적절한 TimePickerState를 onConfirm 함수에 전달하세요. 그러면 상위 컴포저블이 TimePickerState.hour 및 TimePickerState.minute을 통해 선택한 시간에 액세스할 수 있습니다.
varselectedTime:TimePickerState? byremember{mutableStateOf(null)}// ...DialUseStateExample(onDismiss={showDialExample=false},onConfirm={time->
selectedTime=timeshowDialExample=false},)// ...if(selectedTime!=null){valcal=Calendar.getInstance()cal.set(Calendar.HOUR_OF_DAY,selectedTime!!.hour)cal.set(Calendar.MINUTE,selectedTime!!.minute)cal.isLenient=falseText("Selected time = ${formatter.format(cal.time)}")}else{Text("No time selected.")}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-27(UTC)"],[],[],null,["[Time pickers](https://m3.material.io/components/time-pickers/overview) provide a way for users to select a time. You can\nuse the [`TimePicker`](/reference/kotlin/androidx/compose/material3/package-summary#TimePicker(androidx.compose.material3.TimePickerState,androidx.compose.ui.Modifier,androidx.compose.material3.TimePickerColors,androidx.compose.material3.TimePickerLayoutType)) and [`TimeInput`](/reference/kotlin/androidx/compose/material3/package-summary#TimeInput(androidx.compose.material3.TimePickerState,androidx.compose.ui.Modifier,androidx.compose.material3.TimePickerColors)) composables to implement a time\npicker in your app.\n| **Note:** `TimePicker` and `TimeInput` are experimental. File any issues on the [issue tracker](https://issuetracker.google.com/issues/new?component=856989&template=1425922).\n\nTypes\n\nThere are two types of time picker:\n\n- **Dial**: Lets users set a time by moving a handle around a dial.\n- **Input**: Lets users set a time using their keyboard.\n\nThe following image provides an example of a dial time picker on the left, and\nan input time picker on the right:\n**Figure 1.** A dial and an input time picker.\n\nAPI surface\n\nTo implement a time picker, use either the `TimePicker` or `TimeInput`\ncomposable:\n\n- [`TimePicker`](/reference/kotlin/androidx/compose/material3/package-summary#TimePicker(androidx.compose.material3.TimePickerState,androidx.compose.ui.Modifier,androidx.compose.material3.TimePickerColors,androidx.compose.material3.TimePickerLayoutType)): Implements a dial time picker.\n- [`TimeInput`](/reference/kotlin/androidx/compose/material3/package-summary#TimeInput(androidx.compose.material3.TimePickerState,androidx.compose.ui.Modifier,androidx.compose.material3.TimePickerColors)): Implements an input time picker.\n\n| **Note:** While they display different components, `TimePicker` and `TimeInput` are very similar composables in terms of their parameters. They are therefore largely interchangeable.\n\nState\n\nFor both `TimePicker` and `TimeInput`, you must also pass a\n[`TimePickerState`](/reference/kotlin/androidx/compose/material3/TimePickerState). This lets you set the default selected time that appears\non the picker. It also captures the time that the user has selected using the\npicker.\n\nDialog\n\nTime pickers appear in dialogs. The examples in this guide don't use dialogs.\nFor examples that do use dialogs, see the [Dialogs for time pickers](/develop/ui/compose/components/time-pickers-dialogs) guide.\n\nDial time picker\n\nThis snippet demonstrates how to implement a basic dial time picker.\n\n\n```kotlin\n@Composable\nfun DialExample(\n onConfirm: () -\u003e Unit,\n onDismiss: () -\u003e Unit,\n) {\n val currentTime = Calendar.getInstance()\n\n val timePickerState = rememberTimePickerState(\n initialHour = currentTime.get(Calendar.HOUR_OF_DAY),\n initialMinute = currentTime.get(Calendar.MINUTE),\n is24Hour = true,\n )\n\n Column {\n TimePicker(\n state = timePickerState,\n )\n Button(onClick = onDismiss) {\n Text(\"Dismiss picker\")\n }\n Button(onClick = onConfirm) {\n Text(\"Confirm selection\")\n }\n }\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/components/TimePickers.kt#L178-L202\n```\n\n\u003cbr /\u003e\n\nConsider the following in this snippet:\n\n- `Calendar.getInstance()` initializes the `TimePickerState` with the current time.\n - This example uses `java.util.Calendar`. Enable [Java\n 8+ API desugaring](/studio/write/java8-support#library-desugaring) in your project to alternatively use `java.time.LocalTime` on all Android versions.\n- The `TimePicker` composable displays the time picker, taking `timePickerState` as a parameter.\n- The implementation includes two buttons: one to confirm the selection and another to dismiss the picker.\n\nThis implementation appears as follows:\n**Figure 2.** A dial time picker.\n\nInput time picker\n\nThis snippet demonstrates how to implement a basic input style time picker.\n\n\n```kotlin\n@Composable\nfun InputExample(\n onConfirm: () -\u003e Unit,\n onDismiss: () -\u003e Unit,\n) {\n val currentTime = Calendar.getInstance()\n\n val timePickerState = rememberTimePickerState(\n initialHour = currentTime.get(Calendar.HOUR_OF_DAY),\n initialMinute = currentTime.get(Calendar.MINUTE),\n is24Hour = true,\n )\n\n Column {\n TimeInput(\n state = timePickerState,\n )\n Button(onClick = onDismiss) {\n Text(\"Dismiss picker\")\n }\n Button(onClick = onConfirm) {\n Text(\"Confirm selection\")\n }\n }\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/components/TimePickers.kt#L207-L231\n```\n\n\u003cbr /\u003e\n\nKey points to note in this implementation:\n\n- The structure is essentially the same the dial time picker, with the main difference being the use of `TimeInput` instead of `TimePicker`.\n- The `is24Hour` parameter for `timePickerState` is explicitly set to `true`. By default, this value is `false`.\n\nThis implementation appears as follows:\n**Figure 3.** An input time picker.\n\nUse the state\n\nTo make use of the time that the user has selected in a time picker, pass the\nappropriate `TimePickerState` to your `onConfirm` function. The parent\ncomposable can then access the selected time through `TimePickerState.hour` and\n`TimePickerState.minute`.\n\nThe following snippet demonstrates how to do this:\n\n\n```kotlin\n@Composable\nfun DialUseStateExample(\n onConfirm: (TimePickerState) -\u003e Unit,\n onDismiss: () -\u003e Unit,\n) {\n val currentTime = Calendar.getInstance()\n\n val timePickerState = rememberTimePickerState(\n initialHour = currentTime.get(Calendar.HOUR_OF_DAY),\n initialMinute = currentTime.get(Calendar.MINUTE),\n is24Hour = true,\n )\n\n Column {\n TimePicker(\n state = timePickerState,\n )\n Button(onClick = onDismiss) {\n Text(\"Dismiss picker\")\n }\n Button(onClick = { onConfirm(timePickerState) }) {\n Text(\"Confirm selection\")\n }\n }\n}https://github.com/android/snippets/blob/5673ffc60b614daf028ee936227128eb8c4f9781/compose/snippets/src/main/java/com/example/compose/snippets/components/TimePickers.kt#L236-L260\n```\n\n\u003cbr /\u003e\n\nYou could then call the composable like this: \n\n var selectedTime: TimePickerState? by remember { mutableStateOf(null) }\n\n // ...\n\n DialUseStateExample(\n onDismiss = {\n showDialExample = false\n },\n onConfirm = {\n time -\u003e\n selectedTime = time\n showDialExample = false\n },\n )\n\n // ...\n\n if (selectedTime != null) {\n val cal = Calendar.getInstance()\n cal.set(Calendar.HOUR_OF_DAY, selectedTime!!.hour)\n cal.set(Calendar.MINUTE, selectedTime!!.minute)\n cal.isLenient = false\n Text(\"Selected time = ${formatter.format(cal.time)}\")\n } else {\n Text(\"No time selected.\")\n }\n\nFor more detail, see the [full implementation in the snippets\napp](https://github.com/android/snippets/blob/main/compose/snippets/src/main/java/com/example/compose/snippets/components/TimePickers.kt).\n\nAdditional resources\n\n- [`TimePicker`](/reference/kotlin/androidx/compose/material3/package-summary#TimePicker(androidx.compose.material3.TimePickerState,androidx.compose.ui.Modifier,androidx.compose.material3.TimePickerColors,androidx.compose.material3.TimePickerLayoutType))\n- [Material Design - Time Pickers](https://m3.material.io/components/time-pickers/overview)"]]