Top Related Projects
This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
You can now select a date and a time with only one widget !
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
Quick Overview
WheelView is an Android library that provides a customizable wheel-like picker view. It allows users to select items from a circular list, similar to a date picker or time picker, but with the flexibility to display any type of content.
Pros
- Easy to integrate into Android projects
- Highly customizable appearance and behavior
- Smooth scrolling and animation
- Supports both vertical and horizontal orientations
Cons
- Limited documentation and examples
- Not actively maintained (last update was in 2018)
- May require additional work to adapt to modern Android development practices
- Lacks built-in accessibility features
Code Examples
- Basic WheelView setup:
WheelView wheelView = findViewById(R.id.wheelview);
wheelView.setItems(Arrays.asList("Item 1", "Item 2", "Item 3", "Item 4", "Item 5"));
wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
Log.d("WheelView", "Selected item: " + item);
}
});
- Customizing WheelView appearance:
wheelView.setSeletion(2); // Set initial selection
wheelView.setVisibleItemCount(5); // Set number of visible items
wheelView.setTextSize(18); // Set text size
wheelView.setLineColor(Color.GRAY); // Set divider line color
- Using WheelView in horizontal orientation:
wheelView.setOrientation(WheelView.HORIZONTAL);
wheelView.setTextAlign(Paint.Align.CENTER);
Getting Started
- Add the JitPack repository to your project's
build.gradle
file:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
- Add the dependency to your app's
build.gradle
file:
dependencies {
implementation 'com.github.wangjiegulu:WheelView:0.3.3'
}
- Add the WheelView to your layout XML:
<com.wangjie.wheelview.WheelView
android:id="@+id/wheelview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
- Initialize and use the WheelView in your Activity or Fragment as shown in the code examples above.
Competitor Comparisons
This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
Pros of Android-PickerView
- More comprehensive and feature-rich, offering various picker types (time, options, address)
- Better maintained with more recent updates and active community support
- Provides more customization options for appearance and behavior
Cons of Android-PickerView
- Larger library size due to additional features, potentially increasing app size
- Steeper learning curve for developers due to more complex API and options
- May be overkill for simple wheel view implementations
Code Comparison
WheelView:
WheelView wheelView = new WheelView(this);
wheelView.setItems(Arrays.asList("Item 1", "Item 2", "Item 3"));
wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
// Handle selection
}
});
Android-PickerView:
OptionsPickerView<String> optionsPickerView = new OptionsPickerBuilder(this, new OnOptionsSelectListener() {
@Override
public void onOptionsSelect(int options1, int options2, int options3, View v) {
// Handle selection
}
}).build();
optionsPickerView.setPicker(Arrays.asList("Item 1", "Item 2", "Item 3"));
optionsPickerView.show();
Both libraries provide wheel view functionality, but Android-PickerView offers more advanced features and customization options at the cost of increased complexity. WheelView is simpler and more lightweight, suitable for basic wheel view implementations.
You can now select a date and a time with only one widget !
Pros of SingleDateAndTimePicker
- More modern and visually appealing UI design
- Offers both date and time selection in a single view
- Supports customization of colors, fonts, and other visual elements
Cons of SingleDateAndTimePicker
- Limited to date and time selection, less flexible for other types of data
- May have a steeper learning curve due to more complex implementation
- Potentially larger library size due to additional features
Code Comparison
SingleDateAndTimePicker:
new SingleDateAndTimePicker.Builder(context)
.bottomSheet()
.curved()
.displayMinutes(false)
.displayHours(false)
.displayDays(false)
.displayMonth(true)
.displayYears(true)
.displayDaysOfMonth(true)
.listener(new SingleDateAndTimePickerDialog.Listener() {
@Override
public void onDateSelected(Date date) {
// Handle date selection
}
})
.display();
WheelView:
WheelView wheelView = (WheelView) findViewById(R.id.wheelview);
wheelView.setOffset(1);
wheelView.setItems(Arrays.asList("item1", "item2", "item3"));
wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
// Handle item selection
}
});
The code comparison shows that SingleDateAndTimePicker offers more built-in options for date and time selection, while WheelView provides a more generic approach for creating scrollable wheel-like views with custom data.
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
Pros of BetterPickers
- More comprehensive set of pickers (date, time, number, recurrence)
- Material Design styling options
- Better documentation and examples
Cons of BetterPickers
- Larger library size due to more features
- Potentially more complex to implement for simple use cases
- Less customization for individual wheel components
Code Comparison
WheelView:
WheelView wheelView = findViewById(R.id.wheelview);
wheelView.setItems(Arrays.asList("Item 1", "Item 2", "Item 3"));
wheelView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
// Handle selection
}
});
BetterPickers:
NumberPickerBuilder npb = new NumberPickerBuilder()
.setFragmentManager(getSupportFragmentManager())
.setStyleResId(R.style.BetterPickersDialogFragment)
.setTargetFragment(this, 0)
.setReference(1)
.setMinNumber(BigDecimal.ZERO)
.setMaxNumber(BigDecimal.valueOf(100))
.setDecimalVisibility(NumberPicker.INVISIBLE);
npb.show();
The WheelView code is simpler for basic wheel selection, while BetterPickers offers more configuration options but requires more setup code. WheelView focuses on a single wheel component, whereas BetterPickers provides a complete dialog-based picker with additional features.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
WheelView
æåæ个广ååï¼é¿éå·´å·´ï¼æå·æææ¯ï¼æ¯æçµè¯è§é¢é¢è¯ï¼æå ´è¶£çåå¦æ³è¿éï¼https://github.com/wangjiegulu/jobs
How to use
layout:
<com.wangjie.wheelview.WheelView
android:id="@+id/main_wv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Activity:
WheelView wva = (WheelView) findViewById(R.id.main_wv);
wva.setOffset(1);
wva.setItems(Arrays.asList(PLANETS));
wva.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
Log.d(TAG, "selectedIndex: " + selectedIndex + ", item: " + item);
}
});
Show in dialog:
View outerView = LayoutInflater.from(this).inflate(R.layout.wheel_view, null);
WheelView wv = (WheelView) outerView.findViewById(R.id.wheel_view_wv);
wv.setOffset(2);
wv.setItems(Arrays.asList(PLANETS));
wv.setSeletion(3);
wv.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
@Override
public void onSelected(int selectedIndex, String item) {
Log.d(TAG, "[Dialog]selectedIndex: " + selectedIndex + ", item: " + item);
}
});
new AlertDialog.Builder(this)
.setTitle("WheelView in Dialog")
.setView(outerView)
.setPositiveButton("OK", null)
.show();
License
Copyright 2014 Wang Jie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Top Related Projects
This is a picker view for android , support linkage effect, timepicker and optionspicker.(时间选择器、省市区三级联动)
You can now select a date and a time with only one widget !
[NO LONGER MAINTAINED] Android library for better Picker DialogFragments
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot