Introduction to WheelView

Customization WheelView, smooth sliding, fully functional, easy to use, highly customized.

WheelView Features

  • Silky smooth scrolling, fast or slow scrolling
  • Flexible data Settings, set data types through generics, flexible and safe
  • Support iOS – like scrolling change sound
  • Support iOS – like 3D effects
  • Under 3D effect, arc offset effect is supported to make it look more three-dimensional
  • Supports nested scrolling and circular scrolling
  • Rich slide monitor, support selected monitor, scrolling state change monitor, etc
  • Two splitter types can be set, as well as other splitter operations
  • Support automatic resizing to make long text appear completely
  • Support to set the display items, set font size, set font, set line spacing and other general operations
  • More customization is on the way

WheelView Preview

1. 2.



(3) (4)

WheelView Usage (Usage)

1. Dependency

Implementation 'com. Making. Zyyoona7: wheelview: 1.0.0'Copy the code

2. Basic Usage

Add in the layout file

    <com.zyyoona7.wheel.WheelView
        android:id="@+id/wheelview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>Copy the code

In the code

Final WheelView<Integer> WheelView = findViewById(R.i.heelView); List<Integer> List = new ArrayList<>(1); for (int i = 0; i < 20; i++) { list.add(i); } // setData wheelview.setdata (list); Wheelview. setTextSize(24f,true); //more...Copy the code

2. Advanced Usage

Q: What if I already have created entities?

Answer: easy to do ~

I’ve used a list of cities as an example (same with other entities)

My city list entity looks like this:

public class CityEntity implements IWheelEntity, Serializable {// Public static final String LEVEL_COUNTRY = "country"; Public static final String level_type = "type "; Public static final String LEVEL_CITY = "city"; Public static final String LEVEL_DISTRICT = "district"; private String citycode; private String adcode; private String name; private String center; private String level; private List<CityEntity> districts; public String getCitycode() { return citycode; } public void setCitycode(String citycode) { this.citycode = citycode; } public String getAdcode() { return adcode; } public void setAdcode(String adcode) { this.adcode = adcode; } public String getName() { return name == null ? "" : name; } public void setName(String name) { this.name = name; } public String getCenter() { return center; } public void setCenter(String center) { this.center = center; } public String getLevel() { return level; } public void setLevel(String level) { this.level = level; } public List<CityEntity> getDistricts() { return districts == null ? new ArrayList<CityEntity>(1) : districts; } public void setDistricts(List<CityEntity> districts) { this.districts = districts; } @Override public String toString() { return "CityEntity{" + "citycode='" + citycode + '\'' + ", adcode='" + adcode + '\'' + ", name='" + name + '\'' + ", center='" + center + '\'' + ", level='" + level + '\'' + ", districts=" + districts + '}'; } @override public String getWheelText() {return name == null? "" : name; }}Copy the code

Notice that my CityEntity implements an IWheelEntity interface that is defined in the WheelView library and then returns the fields you want to display in WheelView in the getWheelText() method.

MainActivity WheelView

WheelView<CityEntity> cityWv=findViewById(R.id.wv_city); / / parse the city List < CityEntity > cityData = ParseHelper. ParseTwoLevelCityList (this); cityWv.setData(cityData);Copy the code

Then, the rendering looks like this

Cool fact: Actually, it is possible not to implement IWheelEntity, but sneak a look at the source code:

// wheelView.java /** * get item text ** @param item item data * @return text content */ protected String getDataText(T item) {if (item == null) { return ""; } else if (item instanceof IWheelEntity) { return ((IWheelEntity) item).getWheelText(); } else if (item instanceof Integer) {// Reserve at least two digits if Integer. Return isIntegerNeedFormat? String.format(Locale.getDefault(), mIntegerFormat, (Integer) item) : String.valueOf(item); } else if (item instanceof String) { return (String) item; } return item.toString(); }Copy the code

The toString() method is executed by default if none of these conditions are met, so it is theoretically possible to return the fields you want to display in the entity’s toString() method, but it is not recommended. After all, the toString() method, in my own way, outputs CityEntity type information — you can also output other information.

Read more on WIKI

Thanks

WheelPicker

Android-PickerView

WheelView

WheelView-3d

DatePicker

LICENSE

Copyright 2018 zyyoona7

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.
Copy the code