可实现三级联动的选择器,高仿iOS的滚轮控件,字体大小自适应

Overview

仿iOS的PickerView控件

可实现单项选择,并支持一二三级联动效果 高仿iOS的滚轮效果,实现字体大小自适应

Preview

Preview

Useage

//选项选择器
CharacterPickerWindow mOptions = new CharacterPickerWindow(activity);
//初始化选项数据
setPickerData(mOptions.getPickerView());
//设置默认选中的三级项目
mOptions.setSelectOptions(0, 0, 0);
//监听确定选择按钮
mOptions.setOnoptionsSelectListener(new OnOptionChangedListener() {
    @Override
    public void onOptionChanged(int options1, int option2, int options3) {
        // TODO 处理选择结果
    }
});
mOptions.showAtLocation(v, Gravity.BOTTOM, 0, 0);

How to

  • Step 1. 把 JitPack repository 添加到build.gradle文件中 repositories的末尾:
repositories {
    maven { url "https://jitpack.io" }
}
  • Step 2. 在你的app build.gradle 的 dependencies 中添加依赖
dependencies {
	compile 'com.github.imkarl:CharacterPickerView:v0.2.8'
}

ChangeLog

0.2.8

  • 新增方法setTypeface(Typeface):用于设置自定义字体

0.2.7

  • CharacterPickerWindow新增方法setMaxTextSize():用于限制字体最大值

0.2.6

  • 修复某些情况下,字体会变得非常大的bug
  • 新增setMaxTextSize():用于限制字体最大值
  • 升级编译工具版本

0.2.5

  • 修复setSelectOptions()无效的bug
  • 修复CharacterPickerWindow弹出时,可以点击到Activity中Button的bug
  • 修复CharacterPickerWindow弹出时,按返回键直接退出Activity的bug
  • 新增setCurrentPosition()、getCurrentPosition()

0.2.4

  • 修复部分情况下选项显示宽度变小的bug
  • 修复一二级同时滑动时,出现index=-1导致程序崩溃
  • 修复三级同时滑动时,偶然出现的数组越界
  • 增加LoopView.items的空数据判断

0.2.0

  • 升级工程编译工具版本
  • 升级3D滚轮控件
  • 完善字体大小自适应
  • 微调选中项改变监听器

Thanks

Comments
  • java.lang.ArithmeticException: divide by zero

    java.lang.ArithmeticException: divide by zero

    当第一列数据滑到最底部时会崩,错误:

    java.lang.ArithmeticException: divide by zero                                                                        
    at com.weidongjian.meitu.wheelviewdemo.view.LoopView.onDraw(LoopView.java:298)
    
    opened by chowaikong 3
  • update the CharacterPickerWindow options ?

    update the CharacterPickerWindow options ?

    Hey ! I stacked with lib design basically (can't found any way) I need to update the options when I change one of the options. Any hint about that ? Regards, Abdellah

    opened by selmanon 2
  • 混淆规则怎么设置?

    混淆规则怎么设置?

    混淆后报错

    SUPPORTED_64_BIT_ABIS=[Ljava.lang.String;@8d24df1
    versionCode=1
    BOARD=hammerhead
    BOOTLOADER=HHZ20h
    TYPE=user
    ID=M4B30X
    TIME=1472688361000
    BRAND=google
    TAG=Build
    SERIAL=068befde003c6e4e
    HARDWARE=hammerhead
    SUPPORTED_ABIS=[Ljava.lang.String;@eb0cdd6
    CPU_ABI=armeabi-v7a
    RADIO=M8974A-2.0.50.2.30
    IS_DEBUGGABLE=false
    MANUFACTURER=LGE
    SUPPORTED_32_BIT_ABIS=[Ljava.lang.String;@625a198
    TAGS=release-keys
    CPU_ABI2=armeabi
    UNKNOWN=unknown
    USER=android-build
    FINGERPRINT=google/hammerhead/hammerhead:6.0.1/M4B30X/3237893:user/release-keys
    HOST=vpec7.mtv.corp.google.com
    PRODUCT=hammerhead
    versionName=1.0
    DISPLAY=M4B30X
    MODEL=Nexus 5
    DEVICE=hammerhead
    java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
    	at com.bigkoo.pickerview.lib.WheelView.void measureTextWidthHeight()(SourceFile:250)
    	at com.bigkoo.pickerview.lib.WheelView.void remeasure()(SourceFile:217)
    	at com.bigkoo.pickerview.lib.WheelView.void setAdapter(com.bigkoo.pickerview.adapter.WheelAdapter)(SourceFile:328)
    	at com.bigkoo.pickerview.view.WheelOptions.void setPicker(java.util.List,java.util.List,java.util.List)(SourceFile:68)
    	at com.bigkoo.pickerview.OptionsPickerView.void setPicker(java.util.List,java.util.List,java.util.List)(SourceFile:522)
    	at com.hulixuehui.app.ui.login.RegisterActivity.void selectCity(java.util.List,java.util.List,java.util.List)(SourceFile:101)
    	at com.hulixuehui.app.ui.login.RegisterViewModel.void selectCity(android.view.View)(SourceFile:129)
    	at com.hulixuehui.app.databinding.ActivityRegisterBinding$OnClickListenerImpl.void onClick(android.view.View)(SourceFile:694)
    	at android.view.View.performClick(View.java:5204)
    	at android.view.View$PerformClick.run(View.java:21153)
    	at android.os.Handler.handleCallback(Handler.java:739)
    	at android.os.Handler.dispatchMessage(Handler.java:95)
    	at android.os.Looper.loop(Looper.java:148)
    	at android.app.ActivityThread.main(ActivityThread.java:5417)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    
    
    opened by XuQK 1
  • squid:S2039 - Member variable visibility should be specified

    squid:S2039 - Member variable visibility should be specified

    This pull request is focused on resolving occurrences of Sonar rule squid:S2039 - Member variable visibility should be specified

    You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=squid:S2039

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 1
  • squid:CommentedOutCodeLine, squid:S00117 - Sections of code should no…

    squid:CommentedOutCodeLine, squid:S00117 - Sections of code should no…

    This pull request is focused on resolving occurrences of Sonar rules squid:CommentedOutCodeLine - Sections of code should not be "commented out" squid:S00117 - Local variable and method parameter names should comply with a naming convention

    You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=squid:CommentedOutCodeLine https://dev.eclipse.org/sonar/coding_rules#q=squid:S00117

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 1
  • Multiple quality improvements

    Multiple quality improvements

    This pull request is focused on resolving occurrences of Sonar rules squid:S1854 - Dead stores should be removed squid:UselessParenthesesCheck - Useless parentheses around expressions should be removed to prevent any misunderstanding

    You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=squid:S1854 https://dev.eclipse.org/sonar/coding_rules#q=squid:UselessParenthesesCheck

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 0
  • squid:CommentedOutCodeLine, squid:S00117 - Sections of code should no…

    squid:CommentedOutCodeLine, squid:S00117 - Sections of code should no…

    This pull request is focused on resolving occurrences of Sonar rules squid:CommentedOutCodeLine - Sections of code should not be "commented out" squid:S00117 - Local variable and method parameter names should comply with a naming convention

    opened by imkarl 0
  • pmd:ImmutableField - Immutable Field

    pmd:ImmutableField - Immutable Field

    This pull request is focused on resolving occurrences of Sonar rule pmd:ImmutableField - Immutable Field

    You can find more information about the issue here: https://dev.eclipse.org/sonar/coding_rules#q=pmd:ImmutableField

    Please let me know if you have any questions.

    M-Ezzat

    opened by m-ezzat 0
Releases(v0.2.8)
Owner
imkarl
imkarl