Skip to content

Commit

Permalink
添加了循环滚动的开关
Browse files Browse the repository at this point in the history
完成了开启循环滚动和关闭循环滚动的效果
todo:
还有一个bug要解决:初始状态错位一格
完善滚动效果
循环滚动到边缘时的回调
  • Loading branch information
penglu20 committed Aug 5, 2016
1 parent c0e49ad commit 5902e77
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 80 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/pl/wheelview/CityPickerLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected void onFinishInflate() {

String defaultProvince = mProvinceList.get(0);
mCityPicker.setData(mAreaDataUtil.getCityByProvince(defaultProvince));
mCityPicker.setDefault(1);
mCityPicker.setDefault(0);

mProvincePicker.setOnSelectListener(new WheelView.OnSelectListener() {
@Override
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/pl/wheelview/FromToTimePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,25 @@ public void setCurrentDate(String from,String to){
mFromMinute=TimeUtil.getMinuteFromTime(from);
mToHour=TimeUtil.getHourFromTime(to);
mToMinute=TimeUtil.getMinuteFromTime(to);

// mWheelFromHour.setItemNumber(3);
// mWheelFromMinute.setItemNumber(5);
// mWheelToHour.setItemNumber(7);
// mWheelToMinute.setItemNumber(9);


mWheelFromHour.setCyclic(false);
mWheelFromMinute.setCyclic(true);
mWheelToHour.setCyclic(false);
mWheelToMinute.setCyclic(true);

mWheelFromHour.setDefault(mFromHour);
mWheelFromMinute.setDefault(mFromMinute);
mWheelToHour.setDefault(mToHour);
mWheelToMinute.setDefault(mToMinute);



WeekDay[] allWeekDays=WeekDay.values();
}

Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/layout/time_picker_situation.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
Expand All @@ -14,7 +15,7 @@

<com.pl.wheelview.WheelView
android:id="@+id/from_hour"

app:isCyclic="false"
style="@style/wheelViewStyle_time"
android:layout_marginLeft="@dimen/margin_double" />

Expand All @@ -30,7 +31,7 @@

<com.pl.wheelview.WheelView
android:id="@+id/from_minute"

app:isCyclic="true"
style="@style/wheelViewStyle_time"
android:layout_marginRight="@dimen/margin_double" />

Expand All @@ -46,6 +47,7 @@

<com.pl.wheelview.WheelView
android:id="@+id/to_hour"
app:isCyclic="false"
style="@style/wheelViewStyle_time"
android:layout_marginLeft="@dimen/margin_double" />

Expand All @@ -62,6 +64,7 @@

<com.pl.wheelview.WheelView
android:id="@+id/to_minute"
app:isCyclic="true"
style="@style/wheelViewStyle_time"
android:layout_marginRight="@dimen/margin_double" />
</LinearLayout>
Expand Down
Loading

0 comments on commit 5902e77

Please sign in to comment.