android多个选择器,类似ios选择

[复制链接]
来自: BlueManlove 分类: Android精品源码 上传时间: 2017-7-6 09:58:37
Tag:

项目介绍:

Download

Download via Gradle:

compile 'com.github.stfalcon:universalpickerdialog:0.1.0'
or Maven:

<dependency>
<groupId>com.github.stfalcon</groupId>
<artifactId>universalpickerdialog</artifactId>
<version>0.1.0</version>
<type>pom</type>
</dependency>
Usage

Implement callback interface:

public class MainActivity extends AppCompatActivity

    implements View.OnClickListener, UniversalPickerDialog.OnPickListener {

Then implement OnPickListener.onPick(int[], int) method:

@Override
public void onPick(int[] selectedValues, int key) {

String str = list.get(selectedValues[0]);
Object obj = array[selectedValues[0]];

/*do some logic*/

}
Now you can build the dialog and show it. Just add these few lines:

new UniversalPickerDialog.Builder(this)

            .setTitle(R.string.hello)
            .setListener(this)
            .setInputs(
                    new UniversalPickerDialog.Input(0, list),
                    new UniversalPickerDialog.Input(2, array)
            )
            .show();

Data set is passing to Picker using Input class that supports lists as well as arrays, so no data conversion is required :)). It takes in constructor default item position in carousel as the first argument and data set as the second.

Builder was extended by a many methods for more flexibility and convenience of use. Here's the full list (you can find the javadoc on each of these methods):

new UniversalPickerDialog.Builder(this)

            .setTitle(R.string.hello)
            .setTitle("Hello!")
            .setTitleColorRes(R.color.green)
            .setTitleColor(Color.GREEN)
            .setBackgroundColorRes(R.color.white)
            .setBackgroundColor(Color.WHITE)
            .setContentTextColorRes(R.color.green)
            .setContentTextColor(Color.GREEN)
            .setPositiveButtonText(R.string.yep)
            .setPositiveButtonText("Yep!")
            .setNegativeButtonText(R.string.nope)
            .setNegativeButtonText("Nope!")
            .setButtonsColor(R.color.green)
            .setButtonsColorRes(Color.GREEN)
            .setPositiveButtonColorRes(R.color.green)
            .setPositiveButtonColor(Color.GREEN)
            .setNegativeButtonColorRes(R.color.red)
            .setNegativeButtonColor(Color.RED)
            .setContentTextSize(16)
            .setListener(this)
            .setInputs(
                    new UniversalPickerDialog.Input(2, list),
                    new UniversalPickerDialog.Input(0, array)
            )
            .setKey(123)
            .build()
            .show();

相关源码推荐:

我来说两句
所有评论(49)
tylz 2017-7-6 10:13:30
不错不错,楼主辛苦了。。。
回复
Mr_Zhao 2017-7-6 10:13:45
支持,感谢,祝巴士越来越好~
回复
遗失的流年 2017-7-6 10:13:48
楼主威武,以后多发干货,多办活动~!
回复
ILI 2017-7-6 10:13:51
感觉楼主很用心,辛苦啦~
回复
九酒 2017-7-6 10:14:18
感谢分享,楼主V5~
回复
ffg12 2017-7-6 10:14:34
感谢分享,安卓巴士有你更精彩:lol
回复
apkbus热心网友 2017-7-6 11:12:41
虽不明,但觉厉!
回复
提取码:  下载次数:27 状态:已购或VIP 售价:10(原价:10)金钱 下载权限:初级码农 
2240 0 27
代码贡献英雄榜
用户名 下载数
联系我们
首页/微信公众账号投稿
帖子代码编辑/版权问题
QQ:435399051,1294855032
如何获得代码达人称号?
如何成为签约作者?
领先的中文移动开发者社区
18620764416
7*24全天服务
意见反馈:1294855032@qq.com

扫一扫关注我们

Powered by Discuz! X3.2© 2001-2019 Comsenz Inc.( 粤ICP备15117877号 )