Android-仿iPhone滚轮控件效果源码下载地址在Linux公社的1号FTP服务器里,下载地址:
FTP地址:ftp://www.linuxidc.com
用户名:www.linuxidc.com
密码:www.muu.cc
在 2011年LinuxIDC.com\9月\Android-仿iPhone滚轮控件效果源码
下载方法见这里 http://www.linuxidc.net/thread-1187-1-1.html
主布局文件
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:background="@drawable/layout_bg"
- android:layout_width="fill_parent">
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="24dp"
- android:layout_gravity="center_horizontal"
- android:textSize="20sp"
- android:textStyle="bold"
- android:text="Please enter PIN"/>
- <LinearLayout
- android:layout_marginTop="24dp"
- android:layout_gravity="center_horizontal"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content">
- <kankan.wheel.widget.WheelView android:id="@+id/passw_1"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView android:id="@+id/passw_2"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView android:id="@+id/passw_3"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView android:id="@+id/passw_4"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView android:id="@+id/passw_5"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView android:id="@+id/passw_6"
- android:layout_height="wrap_content"
- android:layout_width="wrap_content"/>
- </LinearLayout>
- <TextView android:id="@+id/pwd_status"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="24dp"
- android:layout_gravity="center_horizontal"
- android:textSize="18sp"
- android:textColor="#FFF"
- android:text="Wrong PIN"/>
- <Button android:id="@+id/btn_mix"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:layout_marginTop="12dp"
- android:textSize="18sp"
- android:text=" Mix "/>
- </LinearLayout>
- /*
- * Copyright 2010 Yuri Kanivets
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package kankan.wheel.widget;
- public interface WheelAdapter {
- /**
- * Gets items count
- * @return the count of wheel items
- */
- public int getItemsCount();
- /**
- * Gets a wheel item by index.
- *
- * @param index the item index
- * @return the wheel item text or null
- */
- public String getItem(int index);
- /**
- * Gets maximum item length. It is used to determine the wheel width.
- * If -1 is returned there will be used the default wheel width.
- *
- * @return the maximum item length or -1
- */
- public int getMaximumLength();
- }
- /*
- * Copyright 2010 Yuri Kanivets
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package kankan.wheel.widget;
- /**
- * Numeric Wheel adapter.
- */
- public class NumericWheelAdapter implements WheelAdapter {
- /** The default min value */
- public static final int DEFAULT_MAX_VALUE = 9;
- /** The default max value */
- private static final int DEFAULT_MIN_VALUE = 0;
- // Values
- private int minValue;
- private int maxValue;
- // format
- private String format;
- /**
- * Default constructor
- */
- public NumericWheelAdapter() {
- this(DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE);
- }
- /**
- * Constructor
- * @param minValue the wheel min value
- * @param maxValue the wheel max value
- */
- public NumericWheelAdapter(int minValue, int maxValue) {
- this(minValue, maxValue, null);
- }
- /**
- * Constructor
- * @param minValue the wheel min value
- * @param maxValue the wheel max value
- * @param format the format string
- */
- public NumericWheelAdapter(int minValue, int maxValue, String format) {
- this.minValue = minValue;
- this.maxValue = maxValue;
- this.format = format;
- }
- @Override
- public String getItem(int index) {
- if (index >= 0 && index < getItemsCount()) {
- int value = minValue + index;
- return format != null ? String.format(format, value) : Integer.toString(value);
- }
- return null;
- }
- @Override
- public int getItemsCount() {
- return maxValue - minValue + 1;
- }
- @Override
- public int getMaximumLength() {
- int max = Math.max(Math.abs(maxValue), Math.abs(minValue));
- int maxLen = Integer.toString(max).length();
- if (minValue < 0) {
- maxLen++;
- }
- return maxLen;
- }
- }
监听器Listener文件:
- /*
- * Copyright 2010 Yuri Kanivets
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package kankan.wheel.widget;
- /**
- * Wheel scrolled listener interface.
- */
- public interface OnWheelScrollListener {
- /**
- * Callback method to be invoked when scrolling started.
- * @param wheel the wheel view whose state has changed.
- */
- void onScrollingStarted(WheelView wheel);
- /**
- * Callback method to be invoked when scrolling ended.
- * @param wheel the wheel view whose state has changed.
- */
- void onScrollingFinished(WheelView wheel);
- }
- /*
- * Copyright 2010 Yuri Kanivets
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package kankan.wheel.widget;
- /**
- * Wheel changed listener interface.
- * <p>The currentItemChanged() method is called whenever current wheel positions is changed:
- * <li> New Wheel position is set
- * <li> Wheel view is scrolled
- */
- public interface OnWheelChangedListener {
- /**
- * Callback method to be invoked when current item changed
- * @param wheel the wheel view whose state has changed
- * @param oldValue the old value of current item
- * @param newValue the new value of current item
- */
- void onChanged(WheelView wheel, int oldValue, int newValue);
- }
