### Install WheelPicker Dependencies Source: https://context7.com/devaige/wheelpicker/llms.txt Add the library and its required dependencies to your build.gradle.kts file. ```kotlin // build.gradle.kts (Kotlin DSL) implementation("dev.aige.pub:WheelPicker:1.2.3") // Required dependencies (marked as compileOnly since v1.2.2) implementation("org.jetbrains.kotlin:kotlin-stdlib:") implementation("androidx.appcompat:appcompat:") implementation("com.google.code.gson:gson:") // Optional: Jetpack Compose support implementation(platform("androidx.compose:compose-bom:")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.runtime:runtime") ``` -------------------------------- ### Use Built-in WheelPicker Widgets Source: https://github.com/devaige/wheelpicker/wiki/WIKI Example of using a specialized widget like WheelDatePicker in an XML layout. ```xml ``` -------------------------------- ### Configure WheelDayPicker Source: https://context7.com/devaige/wheelpicker/llms.txt Initialize and manage day selection, including year/month constraints and selection listeners. ```kotlin // XML Layout // val dayPicker = findViewById(R.id.dayPicker) // Set year and month to determine available days dayPicker.setYearAndMonth(2024, 2) // February 2024 (leap year = 29 days) // Or set individually dayPicker.year = 2024 dayPicker.month = 2 // 1-12 // Set selected day dayPicker.selectedDay = 15 // Get current day value val currentDay: Int = dayPicker.currentDay // Configure appearance dayPicker.visibleItemCount = 5 dayPicker.isCurved = true // Listen for selection dayPicker.setOnItemSelectedListener { picker, data, position -> val selectedDay = data.toString().toInt() Log.d("DayPicker", "Selected day: $selectedDay") } ``` -------------------------------- ### Implement WheelDatePicker Source: https://context7.com/devaige/wheelpicker/llms.txt Configures a combined date selection widget including year, month, and day wheels with appearance settings and selection listeners. ```kotlin // XML Layout // class DatePickerActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_date_picker) val datePicker = findViewById(R.id.datePicker) // Set year range datePicker.setYearFrame(1990, 2030) // Or set individually datePicker.yearStart = 1990 datePicker.yearEnd = 2030 // Set initial selection datePicker.selectedYear = 2024 datePicker.selectedMonth = 6 datePicker.selectedDay = 15 // Or set year and month together (updates day picker automatically) datePicker.setYearAndMonth(2024, 12) // Configure appearance (applies to all three pickers) datePicker.visibleItemCount = 5 datePicker.isCurved = true datePicker.isAtmospheric = true datePicker.isCyclic = true datePicker.itemTextSize = 48 datePicker.itemTextColor = Color.GRAY datePicker.selectedItemTextColor = Color.BLACK datePicker.itemSpace = 16 datePicker.isIndicator = true datePicker.indicatorColor = Color.BLUE datePicker.isCurtain = false // Set individual wheel alignments datePicker.itemAlignYear = WheelPicker.ALIGN_RIGHT datePicker.itemAlignMonth = WheelPicker.ALIGN_CENTER datePicker.itemAlignDay = WheelPicker.ALIGN_LEFT // Access individual picker components val yearPicker = datePicker.wheelYearPicker val monthPicker = datePicker.wheelMonthPicker val dayPicker = datePicker.wheelDayPicker // Access label TextViews for customization datePicker.textViewYear.text = "Year" datePicker.textViewMonth.text = "Month" datePicker.textViewDay.text = "Day" // Listen for date selection datePicker.setOnDateSelectedListener(object : WheelDatePicker.OnDateSelectedListener { override fun onDateSelected(picker: WheelDatePicker, date: Date) { val formatter = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) Log.d("DatePicker", "Selected date: ${formatter.format(date)}") } }) // Get current selection val currentDate: Date = datePicker.currentDate val currentYear: Int = datePicker.currentYear val currentMonth: Int = datePicker.currentMonth val currentDay: Int = datePicker.currentDay } } ``` -------------------------------- ### Implement WheelMonthPicker Source: https://context7.com/devaige/wheelpicker/llms.txt Configures a month selection widget with support for cyclic scrolling and appearance customization. ```kotlin // XML Layout // val monthPicker = findViewById(R.id.monthPicker) // Set selected month (1-12, defaults to current month) monthPicker.selectedMonth = 6 // Get current month value val currentMonth: Int = monthPicker.currentMonth // Configure appearance monthPicker.visibleItemCount = 5 monthPicker.isCurved = true monthPicker.isCyclic = true // Enable cycling through months // Listen for selection monthPicker.setOnItemSelectedListener { picker, data, position -> val selectedMonth = data.toString().toInt() Log.d("MonthPicker", "Selected month: $selectedMonth") } ``` -------------------------------- ### Configure WheelPicker Core Component Source: https://context7.com/devaige/wheelpicker/llms.txt Initialize the WheelPicker in an Activity, configure its appearance, and attach listeners for selection and scroll events. ```kotlin // XML Layout // class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val wheelPicker = findViewById(R.id.wheelPicker) // Set data source wheelPicker.data = listOf("Apple", "Banana", "Cherry", "Date", "Elderberry") // Configure appearance wheelPicker.visibleItemCount = 5 // Must be odd number wheelPicker.isCyclic = true // Enable infinite scroll wheelPicker.isCurved = true // Enable 3D curved effect wheelPicker.isAtmospheric = true // Enable transparency fade wheelPicker.isIndicator = true // Show selection indicator wheelPicker.indicatorColor = Color.RED wheelPicker.indicatorSize = 2 wheelPicker.isCurtain = true // Show selection highlight wheelPicker.curtainColor = Color.parseColor("#88FFFFFF") wheelPicker.itemTextSize = 48 // Size in pixels wheelPicker.itemTextColor = Color.GRAY wheelPicker.selectedItemTextColor = Color.BLACK wheelPicker.itemSpace = 20 // Space between items in pixels wheelPicker.itemAlign = WheelPicker.ALIGN_CENTER // ALIGN_LEFT, ALIGN_RIGHT wheelPicker.selectedItemPosition = 2 // Set initial selection // Listen for selection changes wheelPicker.setOnItemSelectedListener { picker, data, position -> Log.d("WheelPicker", "Selected: $data at position $position") } // Alternative: Interface-based listener wheelPicker.setOnItemSelectedListener(object : WheelPicker.OnItemSelectedListener { override fun onItemSelected(picker: WheelPicker, data: Any?, position: Int) { println("Selected item: $data") } }) // Listen for scroll state changes wheelPicker.setOnWheelChangeListener(object : WheelPicker.OnWheelChangeListener { override fun onWheelScrolled(offset: Int) { // Called during scrolling with offset from initial position } override fun onWheelSelected(position: Int) { // Called when scroll stops } override fun onWheelScrollStateChanged(state: Int) { when (state) { WheelPicker.SCROLL_STATE_IDLE -> println("Idle") WheelPicker.SCROLL_STATE_DRAGGING -> println("Dragging") WheelPicker.SCROLL_STATE_SCROLLING -> println("Scrolling") } } }) // Get current selection val currentPosition = wheelPicker.currentItemPosition val currentData = wheelPicker.data?.get(currentPosition) } } ``` -------------------------------- ### Implement WheelAreaPicker Source: https://context7.com/devaige/wheelpicker/llms.txt Access cascading location data and toggle visibility of the district selection level. ```kotlin // XML Layout // val areaPicker = findViewById(R.id.areaPicker) // Get current selection val province: String? = areaPicker.province val city: String? = areaPicker.city val area: String? = areaPicker.area Log.d("AreaPicker", "Location: $province $city $area") // Hide the area/district picker (show only province and city) areaPicker.hideArea() ``` -------------------------------- ### Basic WheelPickerComposable Usage Source: https://context7.com/devaige/wheelpicker/llms.txt Demonstrates the basic integration of WheelPickerComposable with a list of strings. It shows how to display items and capture the selected item and its position. ```kotlin import androidx.compose.foundation.layout.* import androidx.compose.runtime.* import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import com.aigestudio.wheelpicker.WheelPicker import com.aigestudio.wheelpicker.compose.WheelPickerComposable @Composable fun WheelPickerScreen() { var selectedItem by remember { mutableStateOf("") } var selectedPosition by remember { mutableIntStateOf(0) } val fruitList = remember { listOf("Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape") } Column( modifier = Modifier.fillMaxSize().padding(16.dp) ) { Text("Selected: $selectedItem (position: $selectedPosition)") Spacer(modifier = Modifier.height(16.dp)) // Basic usage WheelPickerComposable( data = fruitList, modifier = Modifier.fillMaxWidth().height(200.dp), selectedItemPosition = 2, onItemSelected = { picker, data, position -> selectedItem = data?.toString() ?: "" selectedPosition = position } ) Spacer(modifier = Modifier.height(32.dp)) // Advanced configuration using factory WheelPickerComposable( data = (1..100).map { "Item $it" }, modifier = Modifier.fillMaxWidth().height(250.dp), selectedItemPosition = 50, onItemSelected = { _, data, _ -> println("Selected: $data") }, factory = { // Configure WheelPicker instance isCurved = true isAtmospheric = true isCyclic = true visibleItemCount = 7 itemTextColor = android.graphics.Color.GRAY selectedItemTextColor = android.graphics.Color.BLACK isIndicator = true indicatorColor = android.graphics.Color.parseColor("#EE3333") } ) } } ``` -------------------------------- ### Implement WheelYearPicker Source: https://context7.com/devaige/wheelpicker/llms.txt Configures a year selection widget with a customizable range and selection listener. ```kotlin // XML Layout // val yearPicker = findViewById(R.id.yearPicker) // Set year range (defaults to 1000-3000) yearPicker.setYearFrame(1900, 2100) // Or set individually yearPicker.yearStart = 1900 yearPicker.yearEnd = 2100 // Set selected year (defaults to current year) yearPicker.selectedYear = 2024 // Get current year value val currentYear: Int = yearPicker.currentYear // Configure appearance (inherited from WheelPicker) yearPicker.visibleItemCount = 7 yearPicker.isCurved = true yearPicker.isAtmospheric = true yearPicker.selectedItemTextColor = Color.BLACK // Listen for selection yearPicker.setOnItemSelectedListener { picker, data, position -> val selectedYear = data.toString().toInt() Log.d("YearPicker", "Selected year: $selectedYear") } ``` -------------------------------- ### Classic View System API Source: https://github.com/devaige/wheelpicker/wiki/WIKI Configuration and interaction methods for the classic XML-based WheelPicker view. ```APIDOC ## Classic View System API ### Description Configuration via XML attributes and programmatic interaction using Kotlin/Java methods. ### XML Attributes - **wheel_data** (Reference) - Required - Reference to a string array resource. - **wheel_visible_item_count** (Int) - Optional - Number of visible items (must be odd). - **wheel_curved** (Boolean) - Optional - Enable 3D curved effect. - **wheel_indicator** (Boolean) - Optional - Show/hide selection indicator. ### Methods - **setData(List)** - Sets the data source for the picker. - **setSelectedItemPosition(int)** - Sets the current selected index. - **setOnItemSelectedListener(Listener)** - Sets the listener for selection events. ``` -------------------------------- ### Configure Gradle Dependencies Source: https://github.com/devaige/wheelpicker/wiki/WIKI Add the WheelPicker dependency to your project using Kotlin DSL, Groovy, or Maven. ```kotlin implementation("dev.aige.pub:WheelPicker:1.2.0") ``` ```groovy implementation 'dev.aige.pub:WheelPicker:1.2.0' ``` ```xml dev.aige.pub WheelPicker 1.2.0 pom ``` -------------------------------- ### Interact with WheelPicker in Kotlin and Java Source: https://github.com/devaige/wheelpicker/wiki/WIKI Initialize and set data for the WheelPicker component programmatically. ```kotlin val wheelPicker = findViewById(R.id.wheelPicker) wheelPicker.data = listOf("A", "B", "C", "D") wheelPicker.setOnItemSelectedListener { picker, data, position -> println("Selected: $data") } ``` ```java WheelPicker wheelPicker = findViewById(R.id.wheelPicker); List data = new ArrayList<>(); data.add("A"); data.add("B"); wheelPicker.setData(data); wheelPicker.setOnItemSelectedListener(new WheelPicker.OnItemSelectedListener() { @Override public void onItemSelected(WheelPicker picker, Object data, int position) { System.out.println("Selected: " + data); } }); ``` -------------------------------- ### Configure WheelPicker in XML Layout Source: https://github.com/devaige/wheelpicker/wiki/WIKI Define the WheelPicker component within an XML layout file using custom attributes. ```xml ``` -------------------------------- ### Apply Custom Typeface Source: https://context7.com/devaige/wheelpicker/llms.txt Update the font style of the picker text using asset files or system defaults. ```kotlin val wheelPicker = findViewById(R.id.wheelPicker) // Load typeface from assets val typeface = Typeface.createFromAsset(assets, "fonts/custom_font.ttf") wheelPicker.typeface = typeface // Or use system typefaces wheelPicker.typeface = Typeface.MONOSPACE wheelPicker.typeface = Typeface.DEFAULT_BOLD ``` -------------------------------- ### Implement WheelPicker in Jetpack Compose Source: https://github.com/devaige/wheelpicker/wiki/WIKI Use the WheelPicker composable to display a scrollable selection list. ```kotlin import com.aigestudio.wheelpicker.compose.WheelPicker @Composable fun WheelPickerExample() { // 1. Prepare data val data = (1..100).map { "Item $it" } // 2. Use the Composable WheelPicker( data = data, modifier = Modifier.size(100.dp, 200.dp), selectedItemPosition = 5, visibleItemCount = 7, itemTextSize = 18.sp, itemTextColor = Color.Gray, selectedItemTextColor = Color.Black, onItemSelected = { index, item -> println("Selected: $item at index $index") } ) } ``` -------------------------------- ### WheelAreaPicker Information Source: https://github.com/devaige/wheelpicker/blob/main/README.md Information regarding the WheelAreaPicker. ```APIDOC ## WheelAreaPicker ### Description This picker is designed for selecting administrative regions in China, based on the latest data from the National Bureau of Statistics. ### Data Source Administrative divisions of China according to the National Bureau of Statistics. [Link to data source](http://www.stats.gov.cn/tjsj/tjbz/xzqhdm/201504/t20150415_712722.html) ``` -------------------------------- ### Jetpack Compose Support Dependencies Source: https://github.com/devaige/wheelpicker/blob/main/README.md Include these dependencies in your build.gradle if you are using Jetpack Compose with WheelPicker. ```Gradle // Compose Support (Optional) / Jetpack Compose 支持(可选) implementation(platform("androidx.compose:compose-bom:")) implementation("androidx.compose.ui:ui") implementation("androidx.compose.runtime:runtime") ``` -------------------------------- ### Define WheelPicker XML Attributes Source: https://context7.com/devaige/wheelpicker/llms.txt Configure visual properties and data sources directly within layout XML files. ```xml app:wheel_data="@array/my_items" app:wheel_selected_item_position="0" app:wheel_visible_item_count="7" app:wheel_item_text_size="18sp" app:wheel_item_text_color="#888888" app:wheel_selected_item_text_color="#000000" app:wheel_same_width="false" app:wheel_maximum_width_text="0000" app:wheel_maximum_width_text_position="-1" app:wheel_item_space="16dp" app:wheel_cyclic="false" app:wheel_indicator="true" app:wheel_indicator_color="#EE3333" app:wheel_indicator_size="2dp" app:wheel_curtain="false" app:wheel_curtain_color="#88FFFFFF" app:wheel_atmospheric="true" app:wheel_curved="true" app:wheel_item_align="center" /> ``` -------------------------------- ### Jetpack Compose WheelPicker Source: https://github.com/devaige/wheelpicker/wiki/WIKI Usage of the WheelPicker component within a Jetpack Compose environment. ```APIDOC ## Jetpack Compose WheelPicker ### Description Native support for WheelPicker in Jetpack Compose using the `WheelPicker` composable. ### Parameters - **data** (List) - Required - The list of items to display. - **modifier** (Modifier) - Optional - Layout modifiers. - **selectedItemPosition** (Int) - Optional - The index of the initially selected item. - **visibleItemCount** (Int) - Optional - Number of visible items. - **itemTextSize** (TextUnit) - Optional - Size of the item text. - **itemTextColor** (Color) - Optional - Color of unselected items. - **selectedItemTextColor** (Color) - Optional - Color of the selected item. - **onItemSelected** (Function) - Optional - Callback triggered when an item is selected. ``` -------------------------------- ### WheelDatePicker API Source: https://github.com/devaige/wheelpicker/blob/main/README.md API methods for the WheelDatePicker widget. ```APIDOC ## WheelDatePicker Methods ### Description Methods specific to the WheelDatePicker widget for controlling its appearance and behavior. ### Methods - `setVisibleItemCount(count: Int)`: Sets the number of visible items. - `setCyclic(isCyclic: Boolean)`: Enables or disables cyclic display. - `setSelectedItemTextColor(color: Color)`: Sets the text color for the selected item. - `setItemTextColor(color: Color)`: Sets the text color for non-selected items. - `setItemTextSize(size: Float)`: Sets the text size for items. - `setItemSpace(space: Float)`: Sets the space between items. - `setIndicator(visible: Boolean)`: Shows or hides the indicator. - `setIndicatorColor(color: Color)`: Sets the color of the indicator. - `setIndicatorSize(size: Float)`: Sets the size of the indicator. - `setCurtain(visible: Boolean)`: Shows or hides the curtain. - `setCurtainColor(color: Color)`: Sets the color of the curtain. - `setAtmospheric(enabled: Boolean)`: Enables or disables the atmospheric effect. - `setCurved(enabled: Boolean)`: Enables or disables the curved item effect. - `setItemAlignYear(align: Align)`: Sets the alignment for year items. - `setItemAlignDay(align: Align)`: Sets the alignment for day items. - `setYearFrame(startYear: Int, endYear: Int)`: Sets the frame for selectable years. - `setSelectedItem(year: Int, month: Int, day: Int)`: Sets the initially selected date. - `setSelectedYear(year: Int)`: Sets the selected year. - `setSelectedMonth(month: Int)`: Sets the selected month. - `setSelectedDay(day: Int)`: Sets the selected day. - `getCurrentYear(): Int`: Gets the currently selected year. - `getCurrentMonth(): Int`: Gets the currently selected month. - `getCurrentDay(): Int`: Gets the currently selected day. ``` -------------------------------- ### Core Dependencies for WheelPicker (Version 1.2.2+) Source: https://github.com/devaige/wheelpicker/blob/main/README.md Since version 1.2.2, internal dependencies are marked as compileOnly. Manually add these core dependencies to your project's build.gradle. ```Gradle // Core Dependencies / 核心依赖 implementation("org.jetbrains.kotlin:kotlin-stdlib:") implementation("androidx.appcompat:appcompat:") implementation("com.google.code.gson:gson:") ``` -------------------------------- ### Gradle Dependency for WheelPicker Source: https://github.com/devaige/wheelpicker/blob/main/README.md Add this line to your app's build.gradle file to include the WheelPicker library. ```Gradle implementation 'dev.aige.pub:WheelPicker:1.2.3' ``` -------------------------------- ### WheelPicker Functions Source: https://github.com/devaige/wheelpicker/blob/main/README.md Core functionalities and features of the WheelPicker. ```APIDOC ## WheelPicker Core Functions ### Description Provides core functionalities for creating circular data display pickers with various customization options. ### Functions - Data display circulation - Set visible item count - Get the current item data straight in stationary - Monitor status of scroll get selected item data and other parameter when wheel stop - Dynamic update data - Set text color of selected or non-selected item - Set item space - Support display indicator and set the indicator's size and color - Support display curtain and set the curtain's color - Enable atmospheric effect - Enable perspective effect - Curl the items base on mathematic models - Support item align when perspective or atmospheric enable ``` -------------------------------- ### WheelMonthPicker API Source: https://github.com/devaige/wheelpicker/blob/main/README.md API methods for the WheelMonthPicker widget. ```APIDOC ## WheelMonthPicker Methods ### Description Methods for the WheelMonthPicker widget, inheriting from WheelPicker and providing month-specific controls. ### Methods - All methods of WheelPicker - `setSelectedItem(month: Int)`: Sets the selected month. - `getSelectedMonth(): Int`: Gets the selected month. - `getCurrentMonth(): Int`: Gets the current month. ``` -------------------------------- ### WheelDayPicker API Source: https://github.com/devaige/wheelpicker/blob/main/README.md API methods for the WheelDayPicker widget. ```APIDOC ## WheelDayPicker Methods ### Description Methods for the WheelDayPicker widget, inheriting from WheelPicker and offering day and date-related functionalities. ### Methods - All methods of WheelPicker - `setSelectedItem(day: Int)`: Sets the selected day. - `getSelectedDay(): Int`: Gets the selected day. - `getCurrentDay(): Int`: Gets the current day. - `setYearAndMonth(year: Int, month: Int)`: Sets the year and month context for the day picker. - `setYear(year: Int)`: Sets the year. - `getYear(): Int`: Gets the current year. - `setMonth(month: Int)`: Sets the month. - `getMonth(): Int`: Gets the current month. ``` -------------------------------- ### WheelYearPicker API Source: https://github.com/devaige/wheelpicker/blob/main/README.md API methods for the WheelYearPicker widget. ```APIDOC ## WheelYearPicker Methods ### Description Methods for the WheelYearPicker widget, inheriting all methods from WheelPicker and adding year-specific functionalities. ### Methods - All methods of WheelPicker - `setYearFrame(startYear: Int, endYear: Int)`: Sets the frame for selectable years. - `setYearStart(year: Int)`: Sets the starting year. - `getYearStart(): Int`: Gets the starting year. - `setYearEnd(year: Int)`: Sets the ending year. - `getYearEnd(): Int`: Gets the ending year. - `setSelectedYear(year: Int)`: Sets the selected year. - `getSelectedYear(): Int`: Gets the selected year. - `getCurrentYear(): Int`: Gets the current year. ``` -------------------------------- ### Maven Dependency for WheelPicker Source: https://github.com/devaige/wheelpicker/blob/main/README.md Add this dependency to your Maven project's pom.xml to include the WheelPicker library. ```XML dev.aige.pub WheelPicker 1.2.3 pom ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.