├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── gradle.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ └── output.json
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── teapickerview
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── teapickerview
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── teapickerview
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── image
└── hn2u5-ukvzr.gif
├── pickerviewlibrary
├── .gitignore
├── build.gradle
├── libs
│ └── gson-2.3-sources.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── pickerviewlibrary
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── pickerviewlibrary
│ │ │ └── picker
│ │ │ ├── TeaPickerView.java
│ │ │ ├── adapter
│ │ │ └── DataAdapter.java
│ │ │ ├── entity
│ │ │ ├── PickerData.java
│ │ │ ├── ProvinceBean.java
│ │ │ ├── SecondBean.java
│ │ │ └── ThirdBean.java
│ │ │ ├── listener
│ │ │ └── OnPickerClickListener.java
│ │ │ └── util
│ │ │ └── JsonArrayUtil.java
│ └── res
│ │ ├── anim
│ │ ├── slide_in_from_bottom.xml
│ │ └── slide_out_to_bottom.xml
│ │ ├── color
│ │ └── text_selecter.xml
│ │ ├── drawable
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_quality_selected.png
│ │ ├── layout_sharp.xml
│ │ └── tab_sharp.xml
│ │ ├── layout
│ │ ├── data_textview.xml
│ │ └── picker_view.xml
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── pickerviewlibrary
│ └── ExampleUnitTest.java
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TeaPickerView
2 |
3 | 
4 |
5 | ## 引入module
6 | ```java
7 | allprojects {
8 | repositories {
9 | google()
10 | jcenter()
11 | maven { url 'https://www.jitpack.io' }
12 | }
13 | }
14 | ```
15 | ```java
16 | implementation 'com.github.YangsBryant:TeaPickerView:1.0.2'
17 | ```
18 |
19 | ## 主要代码
20 |
21 | ```java
22 | public class MainActivity extends AppCompatActivity {
23 |
24 | @BindView(R.id.mButton)
25 | Button button;
26 |
27 | List mProvinceDatas=new ArrayList<>();
28 | Map> mSecondDatas= new HashMap<>();
29 | Map> mThirdDatas= new HashMap<>();
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_main);
34 | ButterKnife.bind( this );
35 | intiPickerView();
36 | }
37 |
38 | private void intiPickerView(){
39 | //一级列表
40 | ProvinceBean provinceBean = new ProvinceBean();
41 | mProvinceDatas.addAll(provinceBean.getRepData().getProvince());
42 |
43 | //二级列表
44 | SecondBean secondBean = new SecondBean();
45 | mSecondDatas.putAll(secondBean.getRepData().getSecond());
46 |
47 | //三级列表
48 | ThirdBean thirdBean = new ThirdBean();
49 | mThirdDatas.putAll(thirdBean.getRepData().getThird());
50 |
51 | Log.i("json", JsonArrayUtil.toJson(mProvinceDatas));
52 | Log.i("json",JsonArrayUtil.toJson(mSecondDatas));
53 | Log.i("json",JsonArrayUtil.toJson(mThirdDatas));
54 |
55 | //设置数据有多少层级
56 | PickerData data=new PickerData();
57 | data.setFirstDatas(mProvinceDatas);//json: ["广东","江西"]
58 | data.setSecondDatas(mSecondDatas);//json: {"江西":["南昌","赣州"],"广东":["广州","深圳","佛山","东莞"]}
59 | data.setThirdDatas(mThirdDatas);//json: {"广州":["天河区","白云区","番禹区","花都区"],"赣州":["章贡区","黄金开发区"],"东莞":["东城","南城"],"深圳":["南山区","宝安区","龙华区"],"佛山":["禅城区","顺德区"],"南昌":["东湖区","青云谱区","青山湖区"]}
60 |
61 | data.setInitSelectText("请选择");
62 |
63 | TeaPickerView teaPickerView =new TeaPickerView(this,data);
64 | teaPickerView.setScreenH(3)
65 | .setDiscolourHook(true)
66 | .setRadius(25)
67 | .setContentLine(true)
68 | .setRadius(25)
69 | .build();
70 |
71 | button.setOnClickListener(v -> {
72 | //显示选择器
73 | teaPickerView.show(button);
74 | });
75 |
76 | //选择器点击事件
77 | teaPickerView.setOnPickerClickListener(pickerData -> {
78 | Toast.makeText(MainActivity.this,pickerData.getFirstText()+","+pickerData.getSecondText()+","+pickerData.getThirdText(),Toast.LENGTH_SHORT).show();
79 | teaPickerView.dismiss();//关闭选择器
80 | });
81 | }
82 | }
83 | ```
84 |
85 | ## TeaPickerView属性大全
86 | 方法名 | 属性
87 | --------- | -------------
88 | setHeights(int mHeight) | 显示具体的高度(dp),设置0是自适应(高度没有默认值,需要主动设置)
89 | setScreenH(int num) | 显示的高度占屏幕的百分比
90 | setBackground(int color) | 设置整体的背景颜色 默认是#ffffff
91 | setRadius(int mRadius) | 设置圆角,默认0
92 | setContentBackground(int color) | 内容栏的背景颜色 默认是#ffffff
93 | setContentHeight(int mHeight) | 内容栏的高度(dp) 默认是50dp
94 | setContentText(int size,int color) | 内容栏字体的大小和颜色, 默认是16sp,#0aa666,用此方法会固定颜色
95 | setContentText(ColorStateList drawable) | 自定义内容栏字体颜色变换器 在res目录下创建color文件夹用selector 默认颜色#555 选中颜色#0aa666
96 | setContentLine(boolean bl) | 内容栏选中是否有下划线 默认不开启
97 | setContentLineColor(Drawable drawable) | 自定义内容栏下划线用layer-list 默认是下边框描边 颜色#0fbc72 高度1dp
98 | setLine(int mHeight,int color) | 分割线的高度和颜色 默认是0.5dp #e5e5e5
99 | setitemHeight(int mHeight) | 设置list的item的高度(dp) 默认是40dp
100 | setListText(int size,int color) | 设置list的字体大小和颜色 默认是15 #555
101 | setScrollBal(boolean bl) | 设置list是否显示滚动条,默认false
102 | setAlpha(float mFloat) | 设置阴影层的透明度 默认是0.5f
103 | setDiscolour(boolean bl) | 设置选中项是否加色,默认true
104 | setDiscolourColor(int color) | 设置选中项加色的颜色值,默认#0aa666
105 | setDiscolourHook(boolean bl) | 设置选中项是否有√图标,默认false
106 | setCustomHook(Drawable drawable) | 自定义√图标
107 | build() | 参数设置完毕,一定要build一下
108 |
109 | 方法名 | 属性
110 | --------- | -------------
111 | setInitSelectText(String firstText) | 初始文字
112 | setFirstDatas(List mFirstDatas) | 设置一级数据
113 | setSecondDatas(Map> mSecondDatas) | 设置二级数据
114 | setThirdDatas(Map> mThirdDatas) | 设置三级数据
115 | setFourthDatas(Map> mFourthDatas) | 设置四级数据
116 |
117 | ## 给出参考bean地址
118 | [一级ProvinceBean](https://github.com/YangsBryant/TeaPickerView/blob/master/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/ProvinceBean.java) [二级SecondBean](https://github.com/YangsBryant/TeaPickerView/blob/master/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/SecondBean.java) [三级ThirdBean](https://github.com/YangsBryant/TeaPickerView/blob/master/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/ThirdBean.java)
119 |
120 | ## 默认内容栏字体颜色变换器
121 | ```java
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | ```
131 | ## 默认内容栏下划线
132 | ```java
133 |
134 |
135 |
136 | -
137 |
138 |
139 |
140 |
141 | -
142 |
143 |
144 |
145 |
146 |
147 | ```
148 |
149 | ## 联系QQ:961606042
150 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.example.teapickerview"
7 | minSdkVersion 22
8 | targetSdkVersion 28
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 |
20 | compileOptions {
21 | sourceCompatibility JavaVersion.VERSION_1_8
22 | targetCompatibility JavaVersion.VERSION_1_8
23 | }
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(include: ['*.jar'], dir: 'libs')
28 | implementation 'com.android.support:appcompat-v7:28.0.0'
29 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
30 | testImplementation 'junit:junit:4.12'
31 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
32 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
33 | implementation project(path: ':pickerviewlibrary')
34 | //butterknife
35 | implementation 'com.jakewharton:butterknife:8.8.1'
36 | annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/teapickerview/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.teapickerview;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.teapickerview", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/teapickerview/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.teapickerview;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 | import android.widget.Button;
7 | import android.widget.Toast;
8 | import com.example.pickerviewlibrary.picker.TeaPickerView;
9 | import com.example.pickerviewlibrary.picker.entity.PickerData;
10 | import com.example.pickerviewlibrary.picker.entity.ProvinceBean;
11 | import com.example.pickerviewlibrary.picker.entity.SecondBean;
12 | import com.example.pickerviewlibrary.picker.entity.ThirdBean;
13 | import com.example.pickerviewlibrary.picker.util.JsonArrayUtil;
14 | import java.util.ArrayList;
15 | import java.util.HashMap;
16 | import java.util.List;
17 | import java.util.Map;
18 | import butterknife.BindView;
19 | import butterknife.ButterKnife;
20 |
21 | public class MainActivity extends AppCompatActivity {
22 |
23 | @BindView(R.id.mButton)
24 | Button button;
25 |
26 | List mProvinceDatas=new ArrayList<>();
27 | Map> mSecondDatas= new HashMap<>();
28 | Map> mThirdDatas= new HashMap<>();
29 |
30 | @Override
31 | protected void onCreate(Bundle savedInstanceState) {
32 | super.onCreate(savedInstanceState);
33 | setContentView(R.layout.activity_main);
34 | ButterKnife.bind( this );
35 | intiPickerView();
36 | }
37 |
38 | private void intiPickerView(){
39 | //一级列表
40 | ProvinceBean provinceBean = new ProvinceBean();
41 | mProvinceDatas.addAll(provinceBean.getRepData().getProvince());
42 |
43 | //二级列表
44 | SecondBean secondBean = new SecondBean();
45 | mSecondDatas.putAll(secondBean.getRepData().getSecond());
46 |
47 | //三级列表
48 | ThirdBean thirdBean = new ThirdBean();
49 | mThirdDatas.putAll(thirdBean.getRepData().getThird());
50 |
51 | Log.i("json", JsonArrayUtil.toJson(mProvinceDatas));
52 | Log.i("json",JsonArrayUtil.toJson(mSecondDatas));
53 | Log.i("json",JsonArrayUtil.toJson(mThirdDatas));
54 |
55 | //设置数据有多少层级
56 | PickerData data=new PickerData();
57 | data.setFirstDatas(mProvinceDatas);//json: ["广东","江西"]
58 | data.setSecondDatas(mSecondDatas);//json: {"江西":["南昌","赣州"],"广东":["广州","深圳","佛山","东莞"]}
59 | data.setThirdDatas(mThirdDatas);//json: {"广州":["天河区","白云区","番禹区","花都区"],"赣州":["章贡区","黄金开发区"],"东莞":["东城","南城"],"深圳":["南山区","宝安区","龙华区"],"佛山":["禅城区","顺德区"],"南昌":["东湖区","青云谱区","青山湖区"]}
60 |
61 | data.setInitSelectText("请选择");
62 |
63 | TeaPickerView pickerView=new TeaPickerView(this,data);
64 | pickerView.setScreenH(3)
65 | .setDiscolourHook(true)
66 | .setRadius(25)
67 | .setContentLine(true)
68 | .setRadius(25)
69 | .build();
70 |
71 | button.setOnClickListener(v -> {
72 | //显示选择器
73 | pickerView.show(button);
74 | });
75 |
76 | //选择器点击事件
77 | pickerView.setOnPickerClickListener(pickerData -> {
78 | Toast.makeText(MainActivity.this,pickerData.getFirstText()+","+pickerData.getSecondText()+","+pickerData.getThirdText(),Toast.LENGTH_SHORT).show();
79 | pickerView.dismiss();//关闭选择器
80 | });
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TeaPickerView
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/teapickerview/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.teapickerview;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.3.2'
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 |
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 | maven { url 'https://jitpack.io' }
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 |
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu May 16 15:09:22 CST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/image/hn2u5-ukvzr.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/image/hn2u5-ukvzr.gif
--------------------------------------------------------------------------------
/pickerviewlibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/pickerviewlibrary/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 |
4 | android {
5 | compileSdkVersion 28
6 |
7 | defaultConfig {
8 | minSdkVersion 22
9 | targetSdkVersion 28
10 | versionCode 1
11 | versionName "1.0"
12 |
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 |
15 | }
16 |
17 | buildTypes {
18 | release {
19 | minifyEnabled false
20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21 | }
22 | }
23 |
24 | }
25 |
26 | dependencies {
27 | implementation fileTree(include: ['*.jar'], dir: 'libs')
28 | implementation 'com.android.support:appcompat-v7:28.0.0'
29 | testImplementation 'junit:junit:4.12'
30 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
32 | implementation 'com.android.support:cardview-v7:28.0.0'
33 | implementation files('libs/gson-2.3-sources.jar')
34 | implementation 'com.google.code.gson:gson:2.8.2'
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/pickerviewlibrary/libs/gson-2.3-sources.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/pickerviewlibrary/libs/gson-2.3-sources.jar
--------------------------------------------------------------------------------
/pickerviewlibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/androidTest/java/com/example/pickerviewlibrary/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.pickerviewlibrary.test", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/TeaPickerView.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.ColorStateList;
6 | import android.graphics.Color;
7 | import android.graphics.drawable.Drawable;
8 | import android.graphics.drawable.GradientDrawable;
9 | import android.text.TextUtils;
10 | import android.util.DisplayMetrics;
11 | import android.view.Gravity;
12 | import android.view.LayoutInflater;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.view.WindowManager;
16 | import android.widget.AdapterView;
17 | import android.widget.FrameLayout;
18 | import android.widget.LinearLayout;
19 | import android.widget.ListView;
20 | import android.widget.PopupWindow;
21 | import android.widget.RadioButton;
22 | import android.widget.RadioGroup;
23 | import android.widget.TextView;
24 | import com.example.pickerviewlibrary.R;
25 | import com.example.pickerviewlibrary.picker.adapter.DataAdapter;
26 | import com.example.pickerviewlibrary.picker.entity.PickerData;
27 | import com.example.pickerviewlibrary.picker.listener.OnPickerClickListener;
28 | import java.util.List;
29 | import java.util.Map;
30 |
31 | public class TeaPickerView extends PopupWindow implements View.OnClickListener {
32 | private FrameLayout contentLayout;
33 | private RadioButton mTextFirst, mTextSecond, mTextThird, mTextFourth;
34 | private RadioGroup groupSelect;
35 | private View line;
36 | private ListView pickerList;
37 | private TextView pickerTitleName;
38 | private TextView pickerConfirm;
39 | private View view;
40 | private int index = 1;
41 | private List currData;
42 | private DataAdapter adapter;
43 | private Activity context;
44 | private OnPickerClickListener listener;
45 | private PickerData pickerData;
46 |
47 | private int height;
48 | private int radius = 0;
49 | private int backgroundColor = Color.parseColor("#ffffff");
50 | public static int dataSize = 15;
51 | public static int dataColor ;
52 | public static int dataHeight ;
53 | private float alpha=0.5f;
54 | public static boolean contentLine=false;
55 | public static Drawable contentLineDrawable;
56 | public static boolean scrollBal=false;
57 | public static boolean discolour=true;
58 | public static int discolourColor;
59 | public static boolean discolourHook=false;
60 | public static Drawable customHook;
61 |
62 | public TeaPickerView(Activity context, PickerData pickerData) {
63 | super(context);
64 | this.context = context;
65 | this.pickerData = pickerData;
66 | initView();
67 | }
68 |
69 | //显示具体的高度(dp),设置0是自适应
70 | public TeaPickerView setHeights(int mHeight){
71 | if(mHeight>0){
72 | height = getPixelsFromDp(mHeight);
73 | }
74 | return this;
75 | }
76 |
77 | //显示的高度占屏幕的百分比,高度没有默认值,需要主动设置
78 | public TeaPickerView setScreenH(int num){
79 | if(num>0){
80 | height = getScreenH(context) / num;
81 | }
82 | return this;
83 | }
84 |
85 | //设置整体的背景颜色 默认是#ffffff
86 | public TeaPickerView setBackground(int color){
87 | backgroundColor=color;
88 | return this;
89 | }
90 |
91 | //设置圆角,默认0
92 | public TeaPickerView setRadius(int mRadius){
93 | this.radius = mRadius;
94 | return this;
95 | }
96 |
97 | //内容栏的背景颜色 默认是#ffffff
98 | public TeaPickerView setContentBackground(int color){
99 | GradientDrawable drawable = new GradientDrawable();
100 | //设置圆角大小
101 | drawable.setCornerRadii(new float[]{radius,radius,radius,radius,0,0,0,0});
102 | //设置shape背景色
103 | drawable.setColor(color);
104 | contentLayout.setBackground(drawable);
105 | return this;
106 | }
107 |
108 | //内容栏的高度(dp) 默认是50dp
109 | public TeaPickerView setContentHeight(int mHeight){
110 | FrameLayout.LayoutParams params =(FrameLayout.LayoutParams) groupSelect.getLayoutParams();
111 | params.height = getPixelsFromDp(mHeight);
112 | groupSelect.setLayoutParams(params);
113 | return this;
114 | }
115 |
116 | //内容栏字体的大小和颜色, 默认是16sp,#0aa666,此方法不会变换颜色
117 | public TeaPickerView setContentText(int size, int color){
118 | mTextFirst.setTextSize(size);
119 | mTextFirst.setTextColor(color);
120 | mTextSecond.setTextSize(size);
121 | mTextSecond.setTextColor(color);
122 | mTextThird.setTextSize(size);
123 | mTextThird.setTextColor(color);
124 | mTextFourth.setTextSize(size);
125 | mTextFourth.setTextColor(color);
126 | return this;
127 | }
128 |
129 | //自定义内容栏字体颜色变换器 在res目录下创建color文件夹用selector 默认颜色#555 选中颜色#0aa666
130 | public TeaPickerView setContentText(ColorStateList colorStateList){
131 | mTextFirst.setTextColor(colorStateList);
132 | mTextSecond.setTextColor(colorStateList);
133 | mTextThird.setTextColor(colorStateList);
134 | mTextFourth.setTextColor(colorStateList);
135 | return this;
136 | }
137 |
138 | //内容栏选中是否有下划线 默认不开启
139 | public TeaPickerView setContentLine(boolean bl){
140 | contentLine = bl;
141 | return this;
142 | }
143 |
144 | //自定义内容栏下划线用layer-list 默认是下边框描边 颜色#0fbc72 高度1dp
145 | public TeaPickerView setContentLineColor(Drawable drawable){
146 | contentLineDrawable = drawable;
147 | return this;
148 | }
149 |
150 | //分割线的高度和颜色 默认是0.5dp #e5e5e5
151 | public TeaPickerView setLine(int mHeight, int color){
152 | LinearLayout.LayoutParams params =(LinearLayout.LayoutParams) line.getLayoutParams();
153 | params.height = getPixelsFromDp(mHeight);
154 | line.setLayoutParams(params);
155 | line.setBackgroundColor(color);
156 | return this;
157 | }
158 |
159 | //设置list的item的高度(dp) 默认是40dp
160 | public TeaPickerView setitemHeight(int mHeight){
161 | dataHeight= getPixelsFromDp(mHeight);
162 | return this;
163 | }
164 |
165 | //设置list的字体大小和颜色 默认是15 #555
166 | public TeaPickerView setListText(int size, int color){
167 | dataSize = size;
168 | dataColor = color;
169 | return this;
170 | }
171 |
172 | //设置list是否显示滚动条,默认false
173 | public TeaPickerView setScrollBal(boolean bl){
174 | scrollBal = bl;
175 | return this;
176 | }
177 |
178 | //设置阴影层的透明度 默认是0.5f
179 | public TeaPickerView setAlpha(float mFloat){
180 | alpha = mFloat;
181 | return this;
182 | }
183 |
184 | //设置选中项是否加色,默认true
185 | public TeaPickerView setDiscolour(boolean bl){
186 | discolour = bl;
187 | return this;
188 | }
189 |
190 | //设置选中项加色的颜色值,默认#0aa666
191 | public TeaPickerView setDiscolourColor(int color){
192 | discolourColor = color;
193 | return this;
194 | }
195 |
196 | //设置选中项是否有√图标,默认false
197 | public TeaPickerView setDiscolourHook(boolean bl){
198 | discolourHook = bl;
199 | return this;
200 | }
201 |
202 | //自定义√图标
203 | public TeaPickerView setCustomHook(Drawable drawable){
204 | customHook = drawable;
205 | return this;
206 | }
207 |
208 | //参数设置完毕,一定要build一下
209 | public void build(){
210 | initPicker();
211 | initData();
212 | }
213 |
214 | private GradientDrawable getSharp(){
215 | GradientDrawable drawable = new GradientDrawable();
216 | //设置圆角大小
217 | drawable.setCornerRadii(new float[]{radius,radius,radius,radius,0,0,0,0});
218 | //设置shape背景色
219 | drawable.setColor(backgroundColor);
220 | return drawable;
221 | }
222 |
223 | public void setOnPickerClickListener(OnPickerClickListener listener) {
224 | this.listener = listener;
225 | }
226 |
227 | private void initPicker() {
228 | this.setContentView(view);
229 | this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
230 | if(height>0) {
231 | this.setHeight(height);
232 | }
233 | this.setFocusable(true);
234 | this.setAnimationStyle(R.style.AnimBottom);
235 | this.setBackgroundDrawable(getSharp());
236 | setOnDismissListener(new OnDismissListener() {
237 | @Override
238 | public void onDismiss() {
239 | WindowManager.LayoutParams lp = context.getWindow().getAttributes();
240 | lp.alpha = 1f;
241 | context.getWindow().setAttributes(lp);
242 | }
243 | });
244 | }
245 |
246 | private void initView() {
247 | //默认参数
248 | dataColor = context.getResources().getColor(R.color.picker_text_color);
249 | dataHeight = getPixelsFromDp(40);
250 | discolourColor = context.getResources().getColor(R.color.picker_select_text_color);
251 | contentLineDrawable = context.getResources().getDrawable(R.drawable.tab_sharp);
252 | //加载view
253 | LayoutInflater inflater = (LayoutInflater) context
254 | .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
255 | view = inflater.inflate(R.layout.picker_view, null);
256 | contentLayout = view.findViewById(R.id.contentLayout);
257 | pickerTitleName = view.findViewById(R.id.pickerTitleName);
258 | pickerConfirm = view.findViewById(R.id.pickerConfirm);
259 | groupSelect = view.findViewById(R.id.groupSelect);
260 | mTextFirst = view.findViewById(R.id.mTextFirst);
261 | mTextSecond = view.findViewById(R.id.mTextSecond);
262 | mTextThird = view.findViewById(R.id.mTextThird);
263 | mTextFourth = view.findViewById(R.id.mTextFourth);
264 | line = view.findViewById(R.id.line);
265 | pickerList = view.findViewById(R.id.pickerList);
266 | mTextFirst.setOnClickListener(this);
267 | mTextSecond.setOnClickListener(this);
268 | mTextThird.setOnClickListener(this);
269 | pickerConfirm.setOnClickListener(this);
270 |
271 |
272 | if (!TextUtils.isEmpty(pickerData.getPickerTitleName())){
273 | pickerTitleName.setText(pickerData.getPickerTitleName());
274 | }
275 |
276 | }
277 |
278 | public void show(View view) {
279 | WindowManager.LayoutParams lp = context.getWindow().getAttributes();
280 | lp.alpha = alpha;
281 | context.getWindow().setAttributes(lp);
282 | showAtLocation(view, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
283 | switch (index){
284 | case 1:
285 | adapter.setList(currData,mTextFirst.getText().toString());
286 | underlineState();
287 | break;
288 | case 2:
289 | adapter.setList(currData,mTextSecond.getText().toString());
290 | underlineState();
291 | break;
292 | case 3:
293 | adapter.setList(currData,mTextThird.getText().toString());
294 | underlineState();
295 | break;
296 | case 4:
297 | adapter.setList(currData,mTextFourth.getText().toString());
298 | underlineState();
299 | break;
300 | }
301 |
302 | }
303 |
304 | private void initData() {
305 | currData = pickerData.getCurrDatas(index, "");
306 | adapter = new DataAdapter(context, currData);
307 | pickerList.setVerticalScrollBarEnabled(scrollBal);
308 | pickerList.setAdapter(adapter);
309 | if (!TextUtils.isEmpty(pickerData.getFirstText())) {
310 | mTextFirst.setText(pickerData.getFirstText());
311 | if (!TextUtils.isEmpty(pickerData.getSecondText())) {
312 | mTextSecond.setText(pickerData.getSecondText());
313 | if (!TextUtils.isEmpty(pickerData.getThirdText())) {
314 | mTextThird.setText(pickerData.getThirdText());
315 | if (!TextUtils.isEmpty(pickerData.getFourthText()))
316 | mTextFourth.setText(pickerData.getFourthText());
317 | }
318 | }
319 | mTextFirst.setChecked(true);
320 | }
321 | pickerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
322 | @Override
323 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
324 | String currText = currData.get(position);
325 | pickerData.clearSelectText(index);
326 | mTextFirst.setText(pickerData.getFirstText());
327 | mTextSecond.setText(pickerData.getSecondText());
328 | mTextThird.setText(pickerData.getThirdText());
329 | if (index == 1) {
330 | pickerData.setFirstText(currText);
331 | mTextFirst.setText(currText);
332 | groupSelect.check(mTextFirst.getId());
333 | new UpdateData(currText,pickerData.getSecondDatas()).invoke();
334 | } else if (index == 2) {
335 | pickerData.setSecondText(currText);
336 | mTextSecond.setText(currText);
337 | groupSelect.check(mTextSecond.getId());
338 | new UpdateData(currText,pickerData.getSecondDatas()).invoke();
339 | } else if (index == 3) {
340 | pickerData.setThirdText(currText);
341 | mTextThird.setText(currText);
342 | groupSelect.check(mTextThird.getId());
343 | new UpdateData(currText,pickerData.getSecondDatas()).invoke();
344 | } else if (index == 4) {
345 | pickerData.setFourthText(currText);
346 | mTextFourth.setText(currText);
347 | groupSelect.check(mTextFourth.getId());
348 | if (listener != null) {
349 | listener.OnPickerClick(pickerData);
350 | }
351 | }
352 | }
353 | });
354 | }
355 |
356 | @Override
357 | public void onClick(View v) {
358 | int id = v.getId();
359 | if (id == R.id.mTextFirst) {
360 | index = 1;
361 | currData = pickerData.getCurrDatas(index, "");
362 | adapter.setList(currData,mTextFirst.getText().toString());
363 | underlineState();
364 | } else if (id == R.id.mTextSecond) {
365 | index = 2;
366 | currData = pickerData.getCurrDatas(index, mTextFirst.getText().toString());
367 | adapter.setList(currData,mTextSecond.getText().toString());
368 | underlineState();
369 | } else if (id == R.id.mTextThird) {
370 | index = 3;
371 | currData = pickerData.getCurrDatas(index, mTextSecond.getText().toString());
372 | adapter.setList(currData,mTextThird.getText().toString());
373 | underlineState();
374 | } else if (id == R.id.mTextFourth) {
375 | index = 4;
376 | currData = pickerData.getCurrDatas(index, mTextFourth.getText().toString());
377 | adapter.setList(currData,mTextFourth.getText().toString());
378 | underlineState();
379 | }
380 | /*else if (id == R.id.pickerConfirm) {
381 | if (listener != null) {
382 | dismiss();
383 | listener.OnPickerConfirmClick(pickerData);
384 | }
385 | }*/
386 | }
387 |
388 | private void underlineState(){
389 | if(!contentLine){
390 | return;
391 | }
392 | switch (index){
393 | case 1:
394 | mTextFirst.setBackground(contentLineDrawable);
395 | mTextSecond.setBackground(null);
396 | mTextThird.setBackground(null);
397 | mTextFourth.setBackground(null);
398 | break;
399 | case 2:
400 | mTextFirst.setBackground(null);
401 | mTextSecond.setBackground(contentLineDrawable);
402 | mTextThird.setBackground(null);
403 | mTextFourth.setBackground(null);
404 | break;
405 | case 3:
406 | mTextFirst.setBackground(null);
407 | mTextSecond.setBackground(null);
408 | mTextThird.setBackground(contentLineDrawable);
409 | mTextFourth.setBackground(null);
410 | break;
411 | case 4:
412 | mTextFirst.setBackground(null);
413 | mTextSecond.setBackground(null);
414 | mTextThird.setBackground(null);
415 | mTextFourth.setBackground(context.getResources().getDrawable(R.drawable.tab_sharp));
416 | break;
417 | }
418 | }
419 |
420 | private class UpdateData {
421 | private String text;
422 | private Map> data;
423 | UpdateData(String text, Map> data) {
424 | this.text = text;
425 | this.data=data;
426 | }
427 | void invoke() {
428 | if (!data.isEmpty()) {
429 | List data = pickerData.getCurrDatas(index+1, text);
430 | if (data!=null&&data.size()>0) {
431 | currData = data;
432 | adapter.setList(currData,text);
433 | underlineState();
434 | index ++;
435 | }else {
436 | if (listener != null) {
437 | listener.OnPickerClick(pickerData);
438 | }
439 | }
440 |
441 | } else {
442 | if (listener != null) {
443 | listener.OnPickerClick(pickerData);
444 | }
445 | }
446 | }
447 | }
448 |
449 |
450 | public int getScreenW(Context aty) {
451 | DisplayMetrics dm = aty.getResources().getDisplayMetrics();
452 | return dm.widthPixels;
453 | }
454 |
455 |
456 | public int getScreenH(Context aty) {
457 | DisplayMetrics dm = aty.getResources().getDisplayMetrics();
458 | return dm.heightPixels;
459 | }
460 |
461 | private int getPixelsFromDp(int size){
462 |
463 | DisplayMetrics metrics =new DisplayMetrics();
464 | context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
465 | return(size * metrics.densityDpi) / DisplayMetrics.DENSITY_DEFAULT;
466 | }
467 | }
468 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/adapter/DataAdapter.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.adapter;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.Context;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.AbsListView;
9 | import android.widget.BaseAdapter;
10 | import android.widget.ImageView;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 | import com.example.pickerviewlibrary.R;
14 | import com.example.pickerviewlibrary.picker.TeaPickerView;
15 |
16 | import java.util.List;
17 |
18 | public class DataAdapter extends BaseAdapter {
19 | private List mDatas;
20 | private Context context;
21 | private String checkStr="";
22 | public DataAdapter(Context context, List mDatas) {
23 | this.context=context;
24 | this.mDatas = mDatas;
25 | }
26 |
27 | @Override
28 | public int getCount() {
29 | return mDatas==null ? 0 :mDatas.size();
30 | }
31 |
32 | @Override
33 | public Object getItem(int position) {
34 | return mDatas.get(position);
35 | }
36 |
37 | @Override
38 | public long getItemId(int position) {
39 | return position;
40 | }
41 |
42 | @SuppressLint("ViewHolder")
43 | @Override
44 | public View getView(int position, View convertView, ViewGroup parent) {
45 | ViewHolder viewHolder;
46 | if (convertView == null) {
47 | viewHolder = new ViewHolder();
48 | convertView= LayoutInflater.from(context).inflate(R.layout.data_textview, parent, false);
49 | viewHolder.data_layout = convertView.findViewById(R.id.data_layout);
50 | viewHolder.textView = convertView.findViewById(R.id.data_text);
51 | viewHolder.data_img = convertView.findViewById(R.id.data_img);
52 | convertView.setTag(viewHolder);
53 | }else{
54 | viewHolder = (ViewHolder) convertView.getTag();
55 | }
56 | viewHolder.textView.setTextSize(TeaPickerView.dataSize);
57 | viewHolder.textView.setTextColor(TeaPickerView.dataColor);
58 | viewHolder.textView.setText(mDatas.get(position));
59 | if(checkStr.equals(mDatas.get(position))&& TeaPickerView.discolour){
60 | viewHolder.textView.setTextColor(TeaPickerView.discolourColor);
61 | }
62 | if(checkStr.equals(mDatas.get(position))&& TeaPickerView.discolourHook){
63 | viewHolder.data_img.setVisibility(View.VISIBLE);
64 | }else{
65 | viewHolder.data_img.setVisibility(View.GONE);
66 | }
67 | if(TeaPickerView.customHook!=null){
68 | viewHolder.data_img.setImageDrawable(TeaPickerView.customHook);
69 | }
70 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(AbsListView.LayoutParams.WRAP_CONTENT, TeaPickerView.dataHeight);
71 | viewHolder.textView.setLayoutParams(params);
72 | return convertView;
73 | }
74 | public void setList(List datas,String toString) {
75 | if (datas != null && datas.size()>0) {
76 | mDatas=datas;
77 | }
78 | checkStr=toString;
79 | notifyDataSetChanged();
80 | }
81 |
82 | class ViewHolder {
83 | TextView textView;
84 | LinearLayout data_layout;
85 | ImageView data_img;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/PickerData.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.entity;
2 |
3 |
4 | import android.util.Log;
5 |
6 | import java.util.ArrayList;
7 | import java.util.HashMap;
8 | import java.util.List;
9 | import java.util.Map;
10 |
11 | public class PickerData {
12 | private List mFirstDatas;
13 | private Map> mSecondDatas = new HashMap<>();
14 | private Map> mThirdDatas = new HashMap<>();
15 | private Map> mFourthDatas = new HashMap<>();
16 | private String firstText="";
17 | private String secondText="";
18 | private String thirdText="";
19 | private String fourthText="";
20 | private String pickerTitleName="";
21 | private int height=0;
22 |
23 | /**
24 | * 获取当前的列表
25 | * @param index 当前层级
26 | * @param currText 当前选中的文字key
27 | * @return 返回当前的数据数组
28 | */
29 | public List getCurrDatas(int index,String currText) {
30 | List curr = new ArrayList<>();
31 | switch (index){
32 | case 1:
33 | curr=mFirstDatas;
34 | break;
35 | case 2:
36 | curr=mSecondDatas.get(currText);
37 | break;
38 | case 3:
39 | curr=mThirdDatas.get(currText);
40 | break;
41 | case 4:
42 | curr=mFourthDatas.get(currText);
43 | break;
44 | }
45 | return curr;
46 | }
47 |
48 | public void setInitSelectText(String firstText) {
49 | this.firstText = firstText;
50 | }
51 | public void setInitSelectText(String firstText, String secondText) {
52 | this.firstText = firstText;
53 | this.secondText = secondText;
54 | }
55 | public void setInitSelectText(String firstText, String secondText, String thirdText) {
56 | this.firstText = firstText;
57 | this.secondText = secondText;
58 | this.thirdText = thirdText;
59 | }
60 | public void setInitSelectText(String firstText, String secondText, String thirdText, String fourthText) {
61 | this.firstText = firstText;
62 | this.secondText = secondText;
63 | this.thirdText = thirdText;
64 | this.fourthText = fourthText;
65 | }
66 | public void clearSelectText(int index) {
67 | Log.i("--","index:"+index);
68 | switch (index){
69 | case 1:
70 | secondText="";
71 | thirdText="";
72 | fourthText="";
73 | break;
74 | case 2:
75 | thirdText="";
76 | fourthText="";
77 | break;
78 | case 3:
79 | fourthText="";
80 | break;
81 | }
82 | }
83 |
84 | public String getSelectText() {
85 | return firstText+secondText+thirdText+fourthText;
86 | }
87 |
88 |
89 | public String getPickerTitleName() {
90 | return pickerTitleName;
91 | }
92 |
93 | public void setPickerTitleName(String pickerTitleName) {
94 | this.pickerTitleName = pickerTitleName;
95 | }
96 |
97 | public int getHeight() {
98 | return height;
99 | }
100 |
101 | public void setHeight(int height) {
102 | this.height = height;
103 | }
104 |
105 | public List getFirstDatas() {
106 | return mFirstDatas;
107 | }
108 |
109 | public void setFirstDatas(List mFirstDatas) {
110 | this.mFirstDatas = mFirstDatas;
111 | }
112 |
113 | public Map> getSecondDatas() {
114 | return mSecondDatas;
115 | }
116 |
117 | public void setSecondDatas(Map> mSecondDatas) {
118 | this.mSecondDatas = mSecondDatas;
119 | }
120 |
121 | public Map> getThirdDatas() {
122 | return mThirdDatas;
123 | }
124 |
125 | public void setThirdDatas(Map> mThirdDatas) {
126 | this.mThirdDatas = mThirdDatas;
127 | }
128 |
129 | public Map> getFourthDatas() {
130 | return mFourthDatas;
131 | }
132 |
133 | public void setFourthDatas(Map> mFourthDatas) {
134 | this.mFourthDatas = mFourthDatas;
135 | }
136 |
137 | public String getFirstText() {
138 | return firstText;
139 | }
140 |
141 | public void setFirstText(String firstText) {
142 | this.firstText = firstText;
143 | }
144 |
145 | public String getSecondText() {
146 | return secondText;
147 | }
148 |
149 | public void setSecondText(String secondText) {
150 | this.secondText = secondText;
151 | }
152 |
153 | public String getThirdText() {
154 | return thirdText;
155 | }
156 |
157 | public void setThirdText(String thirdText) {
158 | this.thirdText = thirdText;
159 | }
160 |
161 | public String getFourthText() {
162 | return fourthText;
163 | }
164 |
165 | public void setFourthText(String fourthText) {
166 | this.fourthText = fourthText;
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/ProvinceBean.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.entity;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class ProvinceBean {
7 |
8 | private String code = "200";
9 | private String msg = "服务器返回成功";
10 | private RepData repData;
11 |
12 | public static class RepData {
13 | private List province;
14 |
15 | public List getProvince() {
16 | List list = new ArrayList<>();
17 | list.add("广东");
18 | list.add("江西");
19 | return list;
20 | }
21 |
22 | public void setProvince(List province) {
23 | this.province = province;
24 | }
25 | }
26 |
27 | public String getCode() {
28 | return code;
29 | }
30 |
31 | public void setCode(String code) {
32 | this.code = code;
33 | }
34 |
35 | public String getMsg() {
36 | return msg;
37 | }
38 |
39 | public void setMsg(String msg) {
40 | this.msg = msg;
41 | }
42 |
43 | public RepData getRepData() {
44 | return repData = new RepData();
45 | }
46 |
47 | public void setRepData(RepData repData) {
48 | this.repData = repData;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/SecondBean.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.entity;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | public class SecondBean {
9 |
10 | private String code = "200";
11 | private String msg = "服务器返回成功";
12 | private RepData repData;
13 |
14 | public static class RepData {
15 | private Map> second;
16 |
17 | public Map> getSecond() {
18 | Map> map = new HashMap<>();
19 |
20 | List list = new ArrayList<>();
21 | list.add("广州");
22 | list.add("深圳");
23 | list.add("佛山");
24 | list.add("东莞");
25 |
26 | List list2 = new ArrayList<>();
27 | list2.add("南昌");
28 | list2.add("赣州");
29 |
30 | map.put("广东",list);
31 | map.put("江西",list2);
32 | return map;
33 | }
34 |
35 | public void setSecond(Map> second) {
36 | this.second = second;
37 | }
38 | }
39 |
40 | public String getCode() {
41 | return code;
42 | }
43 |
44 | public void setCode(String code) {
45 | this.code = code;
46 | }
47 |
48 | public String getMsg() {
49 | return msg;
50 | }
51 |
52 | public void setMsg(String msg) {
53 | this.msg = msg;
54 | }
55 |
56 | public RepData getRepData() {
57 | return repData = new RepData();
58 | }
59 |
60 | public void setRepData(RepData repData) {
61 | this.repData = repData;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/entity/ThirdBean.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.entity;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 | import java.util.Map;
7 |
8 | public class ThirdBean {
9 |
10 | private String code = "200";
11 | private String msg = "服务器返回成功";
12 | private RepData repData;
13 |
14 | public static class RepData {
15 | private Map> third;
16 |
17 | public Map> getThird() {
18 | Map> map = new HashMap<>();
19 |
20 | List list = new ArrayList<>();
21 | list.add("天河区");
22 | list.add("白云区");
23 | list.add("番禹区");
24 | list.add("花都区");
25 |
26 | List list2 = new ArrayList<>();
27 | list2.add("南山区");
28 | list2.add("宝安区");
29 | list2.add("龙华区");
30 |
31 | List list3 = new ArrayList<>();
32 | list3.add("禅城区");
33 | list3.add("顺德区");
34 |
35 | List list4 = new ArrayList<>();
36 | list4.add("东城");
37 | list4.add("南城");
38 |
39 | List list5 = new ArrayList<>();
40 | list5.add("东湖区");
41 | list5.add("青云谱区");
42 | list5.add("青山湖区");
43 |
44 | List list6 = new ArrayList<>();
45 | list6.add("章贡区");
46 | list6.add("黄金开发区");
47 |
48 | map.put("广州",list);
49 | map.put("深圳",list2);
50 | map.put("佛山",list3);
51 | map.put("东莞",list4);
52 | map.put("南昌",list5);
53 | map.put("赣州",list6);
54 | return map;
55 | }
56 |
57 | public void setThird(Map> third) {
58 | this.third = third;
59 | }
60 | }
61 |
62 | public String getCode() {
63 | return code;
64 | }
65 |
66 | public void setCode(String code) {
67 | this.code = code;
68 | }
69 |
70 | public String getMsg() {
71 | return msg;
72 | }
73 |
74 | public void setMsg(String msg) {
75 | this.msg = msg;
76 | }
77 |
78 | public RepData getRepData() {
79 | return repData = new RepData();
80 | }
81 |
82 | public void setRepData(RepData repData) {
83 | this.repData = repData;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/listener/OnPickerClickListener.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.listener;
2 |
3 |
4 | import com.example.pickerviewlibrary.picker.entity.PickerData;
5 |
6 | public interface OnPickerClickListener {
7 | void OnPickerClick(PickerData pickerData);
8 | // void OnPickerConfirmClick(PickerData pickerData);
9 | }
10 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/java/com/example/pickerviewlibrary/picker/util/JsonArrayUtil.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary.picker.util;
2 |
3 | import com.google.gson.Gson;
4 |
5 | public class JsonArrayUtil {
6 |
7 | public static String toJson(Object obj) {
8 | Gson gson = new Gson();
9 | String obj2 = gson.toJson(obj);
10 | return obj2;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/anim/slide_in_from_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/anim/slide_out_to_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/color/text_selecter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/drawable/ic_quality_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/YangsBryant/TeaPickerView/fe9ecc8897894af8b1edda7829cb7663e9ac1077/pickerviewlibrary/src/main/res/drawable/ic_quality_selected.png
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/drawable/layout_sharp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/drawable/tab_sharp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 | -
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/layout/data_textview.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
13 |
22 |
29 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/layout/picker_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
11 |
16 |
17 |
26 |
27 |
38 |
39 |
40 |
44 |
45 |
51 |
52 |
61 |
62 |
70 |
71 |
79 |
80 |
87 |
88 |
89 |
90 |
95 |
96 |
102 |
103 |
104 |
105 |
106 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 | #555
8 | #0aa666
9 | #0fbc72
10 | #000000
11 | #e5e5e5
12 |
13 | #00000000
14 |
15 |
16 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | TeaPickerView
3 |
4 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/pickerviewlibrary/src/test/java/com/example/pickerviewlibrary/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.pickerviewlibrary;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':pickerviewlibrary'
2 |
--------------------------------------------------------------------------------