本文整理汇总了Java中android.widget.NumberPicker.getChildCount方法的典型用法代码示例。如果您正苦于以下问题:Java NumberPicker.getChildCount方法的具体用法?Java NumberPicker.getChildCount怎么用?Java NumberPicker.getChildCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.NumberPicker
的用法示例。
在下文中一共展示了NumberPicker.getChildCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPrepareDialogBuilder
import android.widget.NumberPicker; //导入方法依赖的package包/类
@Override
protected void onPrepareDialogBuilder(final Builder builder) {
super.onPrepareDialogBuilder(builder);
mNumberPicker = new NumberPicker(getContext());
mNumberPicker.setMinValue(mMinValue);
mNumberPicker.setMaxValue(mMaxValue);
mNumberPicker.setValue(mSelectedValue);
mNumberPicker.setWrapSelectorWheel(mWrapSelectorWheel);
mNumberPicker.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
for (int i = 0; i < mNumberPicker.getChildCount(); i++) {
View v = mNumberPicker.getChildAt(i);
if (v instanceof EditText) {
v.setOnKeyListener(new KeyListener());
}
}
final LinearLayout linearLayout = new LinearLayout(this.getContext());
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
linearLayout.setGravity(Gravity.CENTER);
linearLayout.addView(mNumberPicker);
builder.setView(linearLayout);
}
示例2: updateTextAttributesForNumberPicker
import android.widget.NumberPicker; //导入方法依赖的package包/类
static void updateTextAttributesForNumberPicker(NumberPicker picker, /*int textColor,*/ int textSizeSP) {
for (int i = 0; i < picker.getChildCount(); i++){
View child = picker.getChildAt(i);
if (child instanceof EditText) {
try {
Field selectorWheelPaintField = NumberPicker.class.getDeclaredField("mSelectorWheelPaint");
selectorWheelPaintField.setAccessible(true);
Paint wheelPaint = ((Paint)selectorWheelPaintField.get(picker));
//wheelPaint.setColor(textColor);
wheelPaint.setTextSize(spToPixels(picker.getContext(), textSizeSP));
EditText editText = ((EditText) child);
//editText.setTextColor(textColor);
editText.setTextSize(textSizeSP);
picker.invalidate();
break;
}
catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException ignored) {
}
}
}
}
示例3: enableNumberPickerEditing
import android.widget.NumberPicker; //导入方法依赖的package包/类
/**
* Enable or disable NumberPicker editing. We use this to turn
* off editing and this has the effect of removing the blinking
* cursor that is shown by default.
*/
private void enableNumberPickerEditing(NumberPicker numberPicker, boolean enable)
{
int childCount = numberPicker.getChildCount();
for (int i = 0; i < childCount; i++)
{
View childView = numberPicker.getChildAt(i);
if (childView instanceof EditText)
{
EditText editText = (EditText) childView;
editText.setFocusable(enable);
return;
}
}
}
示例4: getChildCount
import android.widget.NumberPicker; //导入方法依赖的package包/类
public static int getChildCount(NumberPicker np) {
try {
if (VERSION.SDK_INT >= 11) {
return np.getChildCount();
}
} catch (Throwable e) {
LOG.w(TAG, "get child count failed(Throwable): " + e.getMessage());
}
return 0;
}