Skip to content

Commit ead0472

Browse files
author
zengsong
committed
Merge remote-tracking branch 'origin/master'
2 parents 1562e05 + c66bd05 commit ead0472

23 files changed

+1271
-1149
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
</activity>
24+
<activity android:name=".TestCircleWheelViewActivity" />
2425
</application>
2526

2627
</manifest>

app/src/main/java/com/bigkoo/pickerviewdemo/MainActivity.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121

2222
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
2323
import com.bigkoo.pickerview.builder.TimePickerBuilder;
24+
import com.bigkoo.pickerview.listener.CustomListener;
2425
import com.bigkoo.pickerview.listener.OnOptionsSelectChangeListener;
2526
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
2627
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
28+
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
2729
import com.bigkoo.pickerview.view.OptionsPickerView;
2830
import com.bigkoo.pickerview.view.TimePickerView;
29-
import com.bigkoo.pickerview.listener.CustomListener;
30-
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
3131
import com.bigkoo.pickerviewdemo.bean.CardBean;
3232
import com.bigkoo.pickerviewdemo.bean.ProvinceBean;
3333

@@ -75,13 +75,16 @@ protected void onCreate(Bundle savedInstanceState) {
7575
btn_CustomTime = (Button) findViewById(R.id.btn_CustomTime);
7676
Button btn_no_linkage = (Button) findViewById(R.id.btn_no_linkage);
7777
Button btn_to_Fragment = (Button) findViewById(R.id.btn_fragment);
78+
Button btn_circle = (Button) findViewById(R.id.btn_circle);
79+
7880

7981
btn_Time.setOnClickListener(this);
8082
btn_Options.setOnClickListener(this);
8183
btn_CustomOptions.setOnClickListener(this);
8284
btn_CustomTime.setOnClickListener(this);
8385
btn_no_linkage.setOnClickListener(this);
8486
btn_to_Fragment.setOnClickListener(this);
87+
btn_circle.setOnClickListener(this);
8588

8689
findViewById(R.id.btn_GotoJsonData).setOnClickListener(this);
8790
findViewById(R.id.btn_lunar).setOnClickListener(this);
@@ -92,7 +95,7 @@ protected void onCreate(Bundle savedInstanceState) {
9295
public void onClick(View v) {
9396
if (v.getId() == R.id.btn_Time && pvTime != null) {
9497
// pvTime.setDate(Calendar.getInstance());
95-
/* pvTime.show(); //show timePicker*/
98+
/* pvTime.show(); //show timePicker*/
9699
pvTime.show(v);//弹出时间选择器,传递参数过去,回调的时候则可以绑定此view
97100
} else if (v.getId() == R.id.btn_Options && pvOptions != null) {
98101
pvOptions.show(); //弹出条件选择器
@@ -108,6 +111,8 @@ public void onClick(View v) {
108111
startActivity(new Intent(MainActivity.this, FragmentTestActivity.class));
109112
} else if (v.getId() == R.id.btn_lunar) {
110113
pvCustomLunar.show();
114+
} else if (v.getId() == R.id.btn_circle) {
115+
startActivity(new Intent(MainActivity.this, TestCircleWheelViewActivity.class));
111116
}
112117
}
113118

@@ -189,7 +194,6 @@ private void setTimePickerChildWeight(View v, float yearWeight, float weight) {
189194

190195

191196
private void initTimePicker() {//Dialog 模式下,在底部弹出
192-
193197
pvTime = new TimePickerBuilder(this, new OnTimeSelectListener() {
194198
@Override
195199
public void onTimeSelect(Date date, View v) {
@@ -212,6 +216,9 @@ public void onClick(View view) {
212216
Log.i("pvTime", "onCancelClickListener");
213217
}
214218
})
219+
.setItemVisibleCount(5) //若设置偶数,实际值会加1(比如设置6,则最大可见条目为7)
220+
.setLineSpacingMultiplier(2.0f)
221+
.isAlphaGradient(true)
215222
.build();
216223

217224
Dialog mDialog = pvTime.getDialog();
@@ -230,14 +237,12 @@ public void onClick(View view) {
230237
if (dialogWindow != null) {
231238
dialogWindow.setWindowAnimations(com.bigkoo.pickerview.R.style.picker_view_slide_anim);//修改动画样式
232239
dialogWindow.setGravity(Gravity.BOTTOM);//改成Bottom,底部显示
233-
dialogWindow.setDimAmount(0.1f);
240+
dialogWindow.setDimAmount(0.3f);
234241
}
235242
}
236243
}
237244

238-
239245
private void initCustomTimePicker() {
240-
241246
/**
242247
* @description
243248
*
@@ -273,7 +278,7 @@ public void onTimeSelect(Date date, View v) {//选中事件回调
273278
.setBgColor(Color.BLACK)//滚轮背景颜色 Night mode
274279
.setSubmitColor(Color.WHITE)
275280
.setCancelColor(Color.WHITE)*/
276-
/*.animGravity(Gravity.RIGHT)// default is center*/
281+
/*.animGravity(Gravity.RIGHT)// default is center*/
277282
.setDate(selectedDate)
278283
.setRangDate(startDate, endDate)
279284
.setLayoutRes(R.layout.pickerview_custom_time, new CustomListener() {
@@ -305,10 +310,8 @@ public void onClick(View v) {
305310
.isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
306311
.setDividerColor(0xFF24AD9D)
307312
.build();
308-
309313
}
310314

311-
312315
private void initOptionPicker() {//条件选择器初始化
313316

314317
/**
@@ -321,7 +324,7 @@ public void onOptionsSelect(int options1, int options2, int options3, View v) {
321324
//返回的分别是三个级别的选中位置
322325
String tx = options1Items.get(options1).getPickerViewText()
323326
+ options2Items.get(options1).get(options2)
324-
/* + options3Items.get(options1).get(options2).get(options3).getPickerViewText()*/;
327+
/* + options3Items.get(options1).get(options2).get(options3).getPickerViewText()*/;
325328
btn_Options.setText(tx);
326329
}
327330
})
@@ -430,6 +433,7 @@ public void onOptionsSelectChanged(int options1, int options2, int options3) {
430433
Toast.makeText(MainActivity.this, str, Toast.LENGTH_SHORT).show();
431434
}
432435
})
436+
.setItemVisibleCount(5)
433437
// .setSelectOptions(0, 1, 1)
434438
.build();
435439
pvNoLinkOptions.setNPicker(food, clothes, computer);
@@ -445,12 +449,10 @@ private String getTime(Date date) {//可根据需要自行截取数据显示
445449
}
446450

447451
private void getOptionData() {
448-
449-
/**
452+
/*
450453
* 注意:如果是添加JavaBean实体数据,则实体类需要实现 IPickerViewData 接口,
451454
* PickerView会通过getPickerViewText方法获取字符串显示出来。
452455
*/
453-
454456
getCardData();
455457
getNoLinkData();
456458

@@ -476,7 +478,6 @@ private void getOptionData() {
476478
options2Items.add(options2Items_01);
477479
options2Items.add(options2Items_02);
478480
options2Items.add(options2Items_03);
479-
480481
/*--------数据源添加完毕---------*/
481482
}
482483

@@ -508,5 +509,4 @@ private void getNoLinkData() {
508509
computer.add("HP");
509510
}
510511

511-
512512
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.bigkoo.pickerviewdemo;
2+
3+
import android.os.Bundle;
4+
import android.support.annotation.Nullable;
5+
import android.support.v7.app.AppCompatActivity;
6+
import android.widget.Toast;
7+
8+
import com.bigkoo.pickerview.adapter.ArrayWheelAdapter;
9+
import com.contrarywind.listener.OnItemSelectedListener;
10+
import com.contrarywind.view.WheelView;
11+
12+
import java.util.ArrayList;
13+
import java.util.List;
14+
15+
/**
16+
* desc:
17+
* author: Created by lixiaotong on 2019-07-30
18+
* e-mail: 516030811@qq.com
19+
*/
20+
public class TestCircleWheelViewActivity extends AppCompatActivity {
21+
22+
@Override
23+
protected void onCreate(@Nullable Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_test_circle_wheelview);
26+
27+
WheelView wheelView = findViewById(R.id.wheelview);
28+
wheelView.setTextSize(20);
29+
wheelView.setLineSpacingMultiplier(2f);
30+
// wheelView.setDividerWidth(6);
31+
wheelView.setDividerType(WheelView.DividerType.CIRCLE);
32+
33+
final List<String> mOptionsItems = new ArrayList<>();
34+
mOptionsItems.add("10");
35+
mOptionsItems.add("20");
36+
mOptionsItems.add("30");
37+
mOptionsItems.add("40");
38+
mOptionsItems.add("50");
39+
mOptionsItems.add("60");
40+
mOptionsItems.add("70");
41+
42+
wheelView.setAdapter(new ArrayWheelAdapter(mOptionsItems));
43+
wheelView.setOnItemSelectedListener(new OnItemSelectedListener() {
44+
@Override
45+
public void onItemSelected(int index) {
46+
Toast.makeText(TestCircleWheelViewActivity.this, "" + mOptionsItems.get(index), Toast.LENGTH_SHORT).show();
47+
}
48+
});
49+
}
50+
}

app/src/main/res/layout/activity_main.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
android:layout_margin="10dp"
7878
android:text="@string/picker_custom_parent" />
7979

80+
<Button
81+
android:id="@+id/btn_circle"
82+
android:layout_width="match_parent"
83+
android:layout_height="50dp"
84+
android:layout_margin="10dp"
85+
android:text="@string/picker_use_circle_divider" />
8086
</LinearLayout>
8187

8288
</ScrollView>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical">
6+
7+
<com.contrarywind.view.WheelView xmlns:app="http://schemas.android.com/apk/res-auto"
8+
android:id="@+id/wheelview"
9+
android:layout_width="match_parent"
10+
android:layout_height="match_parent"
11+
android:layout_centerInParent="true"
12+
app:wheelview_dividerWidth="2dp" />
13+
</RelativeLayout>

app/src/main/res/layout/pickerview_custom_lunar.xml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
android:src="@drawable/to_down" />
2525

2626
<CheckBox
27-
android:layout_centerInParent="true"
2827
android:id="@+id/cb_lunar"
2928
android:layout_width="wrap_content"
3029
android:layout_height="wrap_content"
30+
android:layout_centerInParent="true"
3131
android:layout_marginRight="17dp"
3232
android:text="农历"
3333
android:textColor="#24AD9D"
@@ -55,46 +55,48 @@
5555
<!--此部分需要完整复制过去,删减或者更改ID会导致初始化找不到内容而报空-->
5656
<LinearLayout
5757
android:id="@+id/timepicker"
58-
android:layout_width="fill_parent"
59-
android:layout_height="wrap_content"
58+
android:layout_width="match_parent"
59+
android:layout_height="match_parent"
6060
android:background="@android:color/white"
61+
android:gravity="center"
62+
android:minHeight="150dp"
6163
android:orientation="horizontal">
6264

6365
<com.contrarywind.view.WheelView
6466
android:id="@+id/year"
65-
android:layout_width="fill_parent"
66-
android:layout_height="wrap_content"
67+
android:layout_width="0dp"
68+
android:layout_height="match_parent"
6769
android:layout_weight="1" />
6870

6971
<com.contrarywind.view.WheelView
7072

7173
android:id="@+id/month"
72-
android:layout_width="fill_parent"
73-
android:layout_height="wrap_content"
74+
android:layout_width="0dp"
75+
android:layout_height="match_parent"
7476
android:layout_weight="1.1" />
7577

7678
<com.contrarywind.view.WheelView
7779
android:id="@+id/day"
78-
android:layout_width="fill_parent"
79-
android:layout_height="wrap_content"
80+
android:layout_width="0dp"
81+
android:layout_height="match_parent"
8082
android:layout_weight="1.1" />
8183

8284
<com.contrarywind.view.WheelView
8385
android:id="@+id/hour"
84-
android:layout_width="fill_parent"
85-
android:layout_height="wrap_content"
86+
android:layout_width="0dp"
87+
android:layout_height="match_parent"
8688
android:layout_weight="1.1" />
8789

8890
<com.contrarywind.view.WheelView
8991
android:id="@+id/min"
90-
android:layout_width="fill_parent"
91-
android:layout_height="wrap_content"
92+
android:layout_width="0dp"
93+
android:layout_height="match_parent"
9294
android:layout_weight="1.1" />
9395

9496
<com.contrarywind.view.WheelView
9597
android:id="@+id/second"
96-
android:layout_width="fill_parent"
97-
android:layout_height="wrap_content"
98+
android:layout_width="0dp"
99+
android:layout_height="match_parent"
98100
android:layout_weight="1.1" />
99101
</LinearLayout>
100102

app/src/main/res/layout/pickerview_custom_options.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,27 @@
4646
android:id="@+id/optionspicker"
4747
android:layout_width="fill_parent"
4848
android:layout_height="wrap_content"
49+
android:minHeight="150dp"
50+
android:gravity="center"
4951
android:background="@android:color/white"
5052
android:orientation="horizontal">
5153

5254
<com.contrarywind.view.WheelView
5355
android:id="@+id/options1"
54-
android:layout_width="match_parent"
55-
android:layout_height="wrap_content"
56+
android:layout_width="0dp"
57+
android:layout_height="match_parent"
5658
android:layout_weight="1" />
5759

5860
<com.contrarywind.view.WheelView
5961
android:id="@+id/options2"
60-
android:layout_width="match_parent"
61-
android:layout_height="wrap_content"
62+
android:layout_width="0dp"
63+
android:layout_height="match_parent"
6264
android:layout_weight="1" />
6365

6466
<com.contrarywind.view.WheelView
6567
android:id="@+id/options3"
66-
android:layout_width="match_parent"
67-
android:layout_height="wrap_content"
68+
android:layout_width="0dp"
69+
android:layout_height="match_parent"
6870
android:layout_weight="1" />
6971
</LinearLayout>
7072

0 commit comments

Comments
 (0)