/*
* Copyright (C) 2008 The Android Open Source Project
*
* 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 net.simonvt.numberpicker.view;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import net.simonvt.numberpicker.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.NumberKeyListener;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.LayoutInflater.Filter;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.animation.DecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
//import android.annotation.Widget;
/**
* A widget that enables the user to select a number form a predefined range.
* There are two flavors of this widget and which one is presented to the user
* depends on the current theme.
* <ul>
* <li>
* If the current theme is derived from {@link android.R.style#Theme} the widget
* presents the current value as an editable input field with an increment button
* above and a decrement button below. Long pressing the buttons allows for a quick
* change of the current value. Tapping on the input field allows to type in
* a desired value.
* </li>
* <li>
* If the current theme is derived from {@link android.R.style#Theme_Holo} or
* {@link android.R.style#Theme_Holo_Light} the widget presents the current
* value as an editable input field with a lesser value above and a greater
* value below. Tapping on the lesser or greater value selects it by animating
* the number axis up or down to make the chosen value current. Flinging up
* or down allows for multiple increments or decrements of the current value.
* Long pressing on the lesser and greater values also allows for a quick change
* of the current value. Tapping on the current value allows to type in a
* desired value.
* </li>
* </ul>
* <p>
* For an example of using this widget, see {@link android.widget.TimePicker}.
* </p>
*/
//@Widget
public class NumberPicker extends LinearLayout {
/**
* The number of items show in the selector wheel.
*/
private static final int SELECTOR_WHEEL_ITEM_COUNT = 3;
/**
* The default update interval during long press.
*/
private static final long DEFAULT_LONG_PRESS_UPDATE_INTERVAL = 300;
/**
* The index of the middle selector item.
*/
private static final int SELECTOR_MIDDLE_ITEM_INDEX = SELECTOR_WHEEL_ITEM_COUNT / 2;
/**
* The coefficient by which to adjust (divide) the max fling velocity.
*/
private static final int SELECTOR_MAX_FLING_VELOCITY_ADJUSTMENT = 8;
/**
* The the duration for adjusting the selector wheel.
*/
private static final int SELECTOR_ADJUSTMENT_DURATION_MILLIS = 800;
/**
* The duration of scrolling while snapping to a given position.
*/
private static final int SNAP_SCROLL_DURATION = 300;
/**
* The strength of fading in the top and bottom while drawing the selector.
*/
private static final float TOP_AND_BOTTOM_FADING_EDGE_STRENGTH = 0.9f;
/**
* The default unscaled height of the selection divider.
*/
private static final int UNSCALED_DEFAULT_SELECTION_DIVIDER_HEIGHT = 2;
/**
* The default unscaled distance between the selection dividers.
*/
private static final int UNSCALED_DEFAULT_SELECTION_DIVIDERS_DISTANCE = 48;
/**
* The resource id for the default layout.
*/
private static final int DEFAULT_LAYOUT_RESOURCE_ID = 0;
/**
* Constant for unspecified size.
*/
private static final int SIZE_UNSPECIFIED = -1;
/**
* Use a custom NumberPicker formatting callback to use two-digit minutes
* strings like "01". Keeping a static formatter etc. is the most efficient
* way to do this; it avoids creating temporary objects on every call to
* format().
*/
private static class TwoDigitFormatter implements NumberPicker.Formatter {
final StringBuilder mBuilder = new StringBuilder();
char mZeroDigit;
java.util.Formatter mFmt;
final Object[] mArgs = new Object[1];
TwoDigitFormatter() {
final Locale locale = Locale.getDefault();
init(locale);
}
private void init(Locale locale) {
mFmt = createFormatter(locale);
mZeroDigit = getZeroDigit(locale);
}
public String format(int value) {
final Locale currentLocale = Locale.getDefault();
if (mZeroDigit != getZeroDigit(currentLocale)) {
init(currentLocale);
}
mArgs[0] = value;
mBuilder.delete(0, mBuilder.length());
mFmt.format("%02d", mArgs);
return mFmt.toString();
}
private static char getZeroDigit(Locale locale) {
// return LocaleData.get(locale).zeroDigit;
return new DecimalFormatSymbols(locale).getZeroDigit();
}
private java.util.Formatter createFormatter(Locale locale) {
return new java.util.Formatter(mBuilder, locale);
}
}
private static final TwoDigitFormatter sTwoDigitFormatter = new TwoDigitFormatter();
/**
* @hide
*/
public static final Formatter getTwoDigitFormatter() {
return sTwoDigitFormatter;
}
/**
* The increment button.
*/
private final ImageButton mIncrementButton;
/**
* The decrement button.
*/
private final ImageButton mDecrementButton;
/**
* The text for showing the current value.
*/
private final EditText mInputText;
/**
* The distance between the two selection dividers.
*/
private final int mSelectionDividersDistance;
/**
* The min height of this widget.
*/
private final int mMinHeight;
/**
* The max height of this widget.
*/
private final int mMaxHeight;
/**
* The max width of this widget.
*/
private final int mMinWidth;
/**
* The max width of this widget.
*/
private int mMaxWidth;
/**
* Flag whether to compute the max width.
*/
private final boolean mComputeMaxWidth;
/**
* The height of the text.
*/
private final int mTextSize;
/**
* The height of the gap between text elements if the selector wheel.
*/
private int mS
没有合适的资源?快使用搜索试试~ 我知道了~
android NumberPicker修改选中内容的颜色等
共119个文件
png:48个
class:33个
xml:24个
5星 · 超过95%的资源 需积分: 50 1.5k 下载量 119 浏览量
2014-08-04
19:27:46
上传
评论 10
收藏 224KB ZIP 举报
温馨提示
可以修改选中的字体的颜色、内容等,也可以修改选中的两条线的颜色,具体样式可以看这里:http://blog.csdn.net/the_path/article/details/38334899
资源推荐
资源详情
资源评论
收起资源包目录
android NumberPicker修改选中内容的颜色等 (119个子文件)
resources.ap_ 31KB
SampleActivity.apk 61KB
NumberPicker.class 34KB
NumberPicker$AccessibilityNodeProviderImpl.class 10KB
Scroller.class 7KB
DarkThemeActivity.class 3KB
NumberPicker$InputTextFilter.class 3KB
NumberPicker$PressedStateHelper.class 2KB
NumberPicker$TwoDigitFormatter.class 2KB
LightThemeActivity.class 2KB
NumberPicker$SupportAccessibilityNodeProvider.class 2KB
NumberPicker$ChangeCurrentByOneFromLongPressCommand.class 1KB
R$drawable.class 1KB
NumberPicker$2.class 1KB
R$styleable.class 1KB
NumberPicker$1.class 1KB
NumberPicker$SetSelectionCommand.class 1KB
DarkThemeActivity$1.class 1KB
SampleActivity$2.class 1KB
SampleActivity$1.class 1KB
SampleActivity.class 1KB
DarkThemeActivity$2.class 901B
R$attr.class 871B
NumberPicker$BeginSoftInputOnLongPressCommand.class 837B
NumberPicker$CustomEditText.class 807B
R$id.class 785B
R.class 743B
R$style.class 640B
R$color.class 597B
R$layout.class 596B
NumberPicker$OnScrollListener.class 483B
R$string.class 416B
NumberPicker$OnValueChangeListener.class 361B
BuildConfig.class 357B
NumberPicker$Formatter.class 277B
.classpath 475B
classes.dex 55KB
NumberPicker.java 101KB
R.java 21KB
Scroller.java 17KB
DarkThemeActivity.java 3KB
LightThemeActivity.java 1KB
SampleActivity.java 938B
BuildConfig.java 166B
ic_launcher.png 4KB
ic_launcher.png 4KB
ic_launcher.png 3KB
ic_launcher.png 2KB
ic_launcher.png 2KB
ic_launcher.png 2KB
list_selector_disabled_holo_dark.9.png 218B
list_selector_disabled_holo_light.9.png 217B
list_focused_holo.9.png 208B
list_focused_holo.9.png 208B
list_selector_disabled_holo_light.9.png 204B
list_focused_holo.9.png 203B
list_selector_disabled_holo_dark.9.png 203B
list_focused_holo.9.png 191B
list_selector_disabled_holo_light.9.png 191B
list_selector_disabled_holo_dark.9.png 190B
list_selector_disabled_holo_dark.9.png 190B
list_selector_disabled_holo_dark.9.png 189B
list_selector_disabled_holo_light.9.png 189B
list_selector_disabled_holo_light.9.png 188B
list_focused_holo.9.png 186B
list_pressed_holo_dark.9.png 178B
list_pressed_holo_light.9.png 178B
list_longpressed_holo.9.png 178B
list_longpressed_holo.9.png 176B
list_pressed_holo_dark.9.png 176B
list_pressed_holo_light.9.png 176B
list_pressed_holo_light.9.png 175B
list_longpressed_holo.9.png 175B
list_pressed_holo_dark.9.png 175B
list_selector_disabled_holo_dark.9.png 172B
list_focused_holo.9.png 171B
list_selector_disabled_holo_light.9.png 171B
list_pressed_holo_light.9.png 163B
list_pressed_holo_dark.9.png 163B
list_pressed_holo_dark.9.png 159B
list_pressed_holo_light.9.png 159B
list_pressed_holo_light.9.png 158B
list_longpressed_holo.9.png 158B
list_pressed_holo_dark.9.png 158B
list_longpressed_holo.9.png 154B
list_longpressed_holo.9.png 151B
np_numberpicker_selection_divider.9.png 142B
np_numberpicker_selection_divider.9.png 142B
np_numberpicker_selection_divider.9.png 142B
np_numberpicker_selection_divider.9.png 142B
np_numberpicker_selection_divider.9.png 141B
np_numberpicker_selection_divider.9.png 135B
org.eclipse.core.resources.prefs 57B
.project 850B
project.properties 563B
build.xml 3KB
themes.xml 3KB
popu_picker_time.xml 3KB
item_background_holo_light.xml 2KB
item_background_holo_dark.xml 2KB
共 119 条
- 1
- 2
the_path
- 粉丝: 4
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页