# CursorWheelLayouts
**Repository Path**: aceyun/CursorWheelLayouts
## Basic Information
- **Project Name**: CursorWheelLayouts
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-03-20
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# CursorWheelLayout
CursorWheelLayout is an Android library that allows view to be placed on a rotatable wheel. It behaves like a Circular ListView where items rotate rather than scroll vertically(but without view recycle strategy).
CursorWheelLayout consists of two components , the center item with id `id_wheel_menu_center_item` and the menu items that provided by CycleWheelAdapter.
The CursorWheelLayout can be used as a way to select one item from a list. The `wheelSelectedAngle` attribute determines what position on the wheel is selected.
You can also receive a callback for when an item is clicked, and whether it is selected. Have a look at the sample for a working example!
## Screenshot
![1]
![2]
## Apk
[Download Demo here](https://github.com/BCsl/CursorWheelLayout/tree/master/demo/wheel-v1.01.apk)
## Setup
### Gradle
`compile 'github.hellocsl:CursorWheelLayout:1.1.0'`
### Maven
```xml
github.hellocsl
CursorWheelLayout
1.1.0
pom
```
## Usage
1) Add a custom view in Xml
```xml
```
2) Define your `WheelCycleAdapter`
```java
public class SimpleTextAdapter implements CursorWheelLayout.CycleWheelAdapter{
public int getCount(){
//...
}
public View getView(View parent, int position){
//...
}
public Object getItem(int position){
//...
}
}
```
3) Set your `WheelCycleAdapter` similar to how you would set an adapter with a ListView
```java
SimpleTextAdapter simpleTextAdapter = new SimpleTextAdapter(this, menuItemDatas);
mTestCircleMenuLeft.setAdapter(simpleTextAdapter);
```
## Listener
1) A listener for when the closest item to the `SelectionAngle` changes.
```java
mTestCircleMenuTop.setOnMenuSelectedListener(new CursorWheelLayout.OnMenuSelectedListener() {
@Override
public void onItemSelected(CursorWheelLayout parent, View view, int pos) {
Toast.makeText(MainActivity.this, "Top Menu selected position:" + pos, Toast.LENGTH_SHORT).show();
}
});
```
2) A listener for when an item is clicked.
```java
mTestCircleMenuTop.setOnMenuItemClickListener(new CursorWheelLayout.OnMenuItemClickListener() {
@Override
public void onItemClick(View view, int pos) {
Toast.makeText(MainActivity.this, "Top Menu click position:" + pos, Toast.LENGTH_SHORT).show();
}
});
```
## Useful attributes
Here are the custom attributes that can be declared in xml:
* wheelSelectedAngle
* wheelPaddingRadio
* wheelCenterRadio
* wheelItemRadio
* wheelFlingValue
* wheelCursorHeight
* wheelCursorColor
* wheelBackgroundColor
* wheelItemRotateMode
## Refer to
http://blog.csdn.net/lmj623565791/article/details/43131133
## License
Apache License Version 2.0
http://apache.org/licenses/LICENSE-2.0.txt
[1]: ./screenshot/gif2.gif
[2]: ./screenshot/gif3.gif