前言
上个月的滑轮选择器,今天趁着放假把它修改了下,上传到了开源库中,方便大家的使用,下面说下简单的变化.
实例化类的改变
原先是使用TextPicker类来实例化,现在修改成MyPicker.
MyPicker picker = new MyPicker();
对外方法的增删
使用Demo
tp = new MyPicker(this); //init data initData(); //loding data tp.setData(leftList,1); tp.setData(middleList,2); tp.setData(rightList,3); //set title tp.setPickerTitle(getResources().getString(R.string.title_name)); //set the default centered text //if not set,show centered text in the data tp.setMiddleText(5,1); tp.setMiddleText(2,2); tp.setMiddleText(25,3); //redy tp.setPrepare(); // default show three // tp.setShowNum(3); tp.setSelectedFinishListener(new MyPicker.SelectedFinishListener() { @Override public void onFinish() { leftText = String.valueOf(tp.getText(1)); middleText = String.valueOf(tp.getText(2)); rightText = String.valueOf(tp.getText(3)); tv.setText(leftText+"-"+middleText+"-"+rightText); tp.dismiss(); } }); tp.showAtLocation(this.findViewById(R.id.main),Gravity.CENTER,0);
添加依赖
dependencies { compile 'com.idisfkj.picker:mypicker:1.2.1' }
现在使用只要如上一句代码就可以了,是不是简单许多
结语
如果还想要知道具体原理,可以访问我原来的文章:
或者访问我的个人博客:
Github链接:https://github.com/idisfkj/id...欢迎Fork Star