当前位置: 首页>>代码示例>>Java>>正文


Java NumberPicker类代码示例

本文整理汇总了Java中android.widget.NumberPicker的典型用法代码示例。如果您正苦于以下问题:Java NumberPicker类的具体用法?Java NumberPicker怎么用?Java NumberPicker使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NumberPicker类属于android.widget包,在下文中一共展示了NumberPicker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onHeightClick

import android.widget.NumberPicker; //导入依赖的package包/类
@OnClick(R.id.custom_tile_height_size)
public void onHeightClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileHeight);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileHeight = view.getValue();
              widget.setTileHeightDp(currentTileHeight);
            }
          })
          .show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CustomTileDimensions.java

示例2: onCreate

import android.widget.NumberPicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_study_mode_settings_page);

    biologyButton = (ToggleButton) findViewById(R.id.biologyButton);
    chemistryButton = (ToggleButton) findViewById(R.id.chemistryButton);
    earthAndSpaceButton = (ToggleButton) findViewById(R.id.earthAndSpaceButton);
    energyButton = (ToggleButton) findViewById(R.id.energyButton);
    mathButton = (ToggleButton) findViewById(R.id.mathButton);
    physicsButton = (ToggleButton) findViewById(R.id.physicsButton);
    randomButton = (ToggleButton) findViewById(R.id.randomButton);

    roundNumPicker = (NumberPicker) findViewById(R.id.roundNumPicker);
    roundNumPicker.setMinValue(0);
    roundNumPicker.setMaxValue(roundOptions.length-1);
    roundNumPicker.setWrapSelectorWheel(false);
    roundNumPicker.setDisplayedValues(roundOptions);

    menuButton = (Button) findViewById(R.id.menuButton);
}
 
开发者ID:jakepolatty,项目名称:HighSchoolScienceBowlPractice-Android,代码行数:22,代码来源:StudyModeSettingsPage.java

示例3: playerNumberAlert

import android.widget.NumberPicker; //导入依赖的package包/类
@SuppressWarnings("SameParameterValue")
private void playerNumberAlert(String title, final String preferenceName, int min, int max, int default_num) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    View mView = inflater.inflate(R.layout.dialog_number_picker, (ViewGroup) getActivity().findViewById(R.id.dialog_layout_number_picker));
    final NumberPicker numberPicker = mView.findViewById(R.id.dialog_number_picker);
    numberPicker.setMinValue(min);
    numberPicker.setMaxValue(max);
    numberPicker.setValue(default_num);
    builder.setTitle(title);
    builder.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            sharedPreferences.edit().putInt(preferenceName, numberPicker.getValue()).apply();
        }
    });
    builder.setNegativeButton(android.R.string.no, null);
    builder.setView(mView);
    builder.show();
}
 
开发者ID:XFY9326,项目名称:CatchSpy,代码行数:21,代码来源:GlobalSettingsFragment.java

示例4: onWidthClick

import android.widget.NumberPicker; //导入依赖的package包/类
@OnClick(R.id.custom_tile_width_size)
public void onWidthClick() {
  final NumberPicker view = new NumberPicker(this);
  view.setMinValue(24);
  view.setMaxValue(64);
  view.setWrapSelectorWheel(false);
  view.setValue(currentTileWidth);
  new AlertDialog.Builder(this)
          .setView(view)
          .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(@NonNull DialogInterface dialog, int which) {
              currentTileWidth = view.getValue();
              widget.setTileWidthDp(currentTileWidth);
            }
          })
          .show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CustomTileDimensions.java

示例5: onTileSizeClicked

import android.widget.NumberPicker; //导入依赖的package包/类
@OnClick(R.id.button_set_tile_size)
void onTileSizeClicked() {
    final NumberPicker view = new NumberPicker(this);
    view.setMinValue(24);
    view.setMaxValue(64);
    view.setWrapSelectorWheel(false);
    view.setValue(currentTileSize);
    new AlertDialog.Builder(this)
            .setView(view)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(@NonNull DialogInterface dialog, int which) {
                    currentTileSize = view.getValue();
                    widget.setTileSizeDp(currentTileSize);
                }
            })
            .show();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DynamicSettersActivity.java

示例6: initNumPicker

import android.widget.NumberPicker; //导入依赖的package包/类
/**
 * 初始化传入的moneyPicker
 *
 * @param numberPickerArrayList 需要初始化的NumPicker
 */
private void initNumPicker(ArrayList<NumberPicker> numberPickerArrayList) {
    Iterator iterator = numberPickerArrayList.iterator();
    while (iterator.hasNext()) {
        NumberPicker moneyPicker = (NumberPicker) iterator.next();
        moneyPicker.setFormatter(this);
        moneyPicker.setOnValueChangedListener(this);
        moneyPicker.setOnScrollListener(this);
        moneyPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    }

    numberPickerArrayList.get(0).setMinValue(3);numberPickerArrayList.get(0).setMaxValue(15);//早餐的价格区间
    numberPickerArrayList.get(1).setMinValue(5);numberPickerArrayList.get(1).setMaxValue(30);//午餐的价格区间
    numberPickerArrayList.get(2).setMinValue(5);numberPickerArrayList.get(2).setMaxValue(30);//晚餐的价格区间


    numberPickerArrayList.get(0).setValue(preferences.getInt("moneyBreakfastChosen", 5));//早餐默认为5
    numberPickerArrayList.get(1).setValue(preferences.getInt("moneyLunchChosen", 10));//午饭默认为10
    numberPickerArrayList.get(2).setValue(preferences.getInt("moneyDinnerChosen", 12));//早餐默认为12

}
 
开发者ID:GrayXu,项目名称:HustEating,代码行数:26,代码来源:SettingFragment.java

示例7: initializeViews

import android.widget.NumberPicker; //导入依赖的package包/类
private void initializeViews(Dialog dialog) {
    major = (ToggleButton) dialog.findViewById(R.id.major);
    minor = (ToggleButton) dialog.findViewById(R.id.minor);
    dialog.findViewById(R.id.major_parent).setOnClickListener(__ -> onMajorClicked());
    dialog.findViewById(R.id.minor_parent).setOnClickListener(__ -> onMinorClicked());

    keySigImage = (ImageView) dialog.findViewById(R.id.key_sig_image);

    key = (NumberPicker) dialog.findViewById(R.id.key);
    key.setWrapSelectorWheel(false);
    key.setMinValue(0);
    key.setMaxValue(KeySigHandler.FIFTHS.length - 1);

    major.setChecked(false);
    onMajorClicked();
    key.setOnValueChangedListener(this);
    key.setValue(6);
}
 
开发者ID:joshschriever,项目名称:LiveNotes,代码行数:19,代码来源:KeySigDialogFragment.java

示例8: setNumber

import android.widget.NumberPicker; //导入依赖的package包/类
/**
 * Set value for {@link NumberPicker}
 */
public static ViewAction setNumber(final int n) {
    return new ViewAction() {
        @Override
        public void perform(UiController uiController, View view) {
            ((NumberPicker) view).setValue(n);
        }

        @Override
        public String getDescription() {
            return "Set NumberPicker value";
        }

        @Override
        public Matcher<View> getConstraints() {
            return ViewMatchers.isAssignableFrom(NumberPicker.class);
        }
    };
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:22,代码来源:EspressoUtils.java

示例9: onCreate

import android.widget.NumberPicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_age);
    final EditText ageEdit = (EditText) findViewById(R.id.age);

    ageEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                hideKeyboard(v);
                ageEdit.setCursorVisible(false);
            } else {
                showKeyboard(v);
                ageEdit.setCursorVisible(true);
            }
        }
    });

    NumberPicker numberPicker = (NumberPicker) findViewById(R.id.numberPicker);
    numberPicker.setMaxValue(28);
    numberPicker.setMinValue(1);

    NumberPicker stringPicker = (NumberPicker) findViewById(R.id.stringPicker);
    stringPicker.setMaxValue(2);
    stringPicker.setMinValue(0);
    stringPicker.setDisplayedValues( new String[] { "Days", "Months", "Years" } );

}
 
开发者ID:smajko,项目名称:what_are_those_app,代码行数:30,代码来源:AgeScreen.java

示例10: ListAdapterViewHolder

import android.widget.NumberPicker; //导入依赖的package包/类
public ListAdapterViewHolder(View view) {
    super(view);
    mTextView = (TextView) view.findViewById(R.id.tv_object_data);
    removeButton = (Button) view.findViewById(R.id.remove_button);
    numberPicker = (NumberPicker) view.findViewById(R.id.number_picker);
    numberPicker.setMaxValue(99999);
    numberPicker.setMinValue(0);
    numberPicker.setOnScrollListener(this);
    numberPicker.setOnValueChangedListener(this);
    numberPicker.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            v.performClick();
            return true;
        }
    });
    view.setOnClickListener(this);
}
 
开发者ID:ndleyton,项目名称:OneTwo,代码行数:19,代码来源:ListAdapter.java

示例11: onCreate

import android.widget.NumberPicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reader_mode_settings_page);

    setNumPicker = (NumberPicker) findViewById(R.id.setNumPicker);
    setNumPicker.setMinValue(0);
    setNumPicker.setMaxValue(setOptions.length-1);
    setNumPicker.setWrapSelectorWheel(false);
    setNumPicker.setDisplayedValues(setOptions);

    roundNumPicker = (NumberPicker) findViewById(R.id.roundNumPicker);
    roundNumPicker.setMinValue(0);
    roundNumPicker.setMaxValue(roundOptions.length-1);
    roundNumPicker.setWrapSelectorWheel(false);
    roundNumPicker.setDisplayedValues(roundOptions);

    tossupTimeSpinner = (Spinner) findViewById(R.id.tossupTimeSelector);
    bonusTimeSpinner = (Spinner) findViewById(R.id.bonusTimeSelector);

    menuButton = (Button) findViewById(R.id.menuButton);
}
 
开发者ID:jakepolatty,项目名称:HighSchoolScienceBowlPractice-Android,代码行数:23,代码来源:ReaderModeSettingsPage.java

示例12: onCreate

import android.widget.NumberPicker; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);

    NumberPicker stockNumberPicker = (NumberPicker) findViewById(R.id.stock);
    stockNumberPicker.setMinValue(0);
    stockNumberPicker.setMaxValue(10);

    FitterNumberPicker defaultNumberPicker = (FitterNumberPicker) findViewById(R.id.default_number_picker);
    FitterNumberPicker customNumberPicker = (FitterNumberPicker) findViewById(R.id.custom_number_picker);

    ViewConfiguration configuration = ViewConfiguration.get(this);
    //This would be a good value to start with, then / or * to adjust
    //By default, the velocity is divided by 8, so do what you want to adjust
    int maxFlingVelocity = configuration.getScaledMaximumFlingVelocity() / 6;
    customNumberPicker.setMaximumFlingVelocity(maxFlingVelocity);
}
 
开发者ID:Commit451,项目名称:FitterNumberPicker,代码行数:22,代码来源:MainActivity.java

示例13: setSeparatorColor

import android.widget.NumberPicker; //导入依赖的package包/类
/**
 * Uses reflection to access divider private attribute and override its color
 * Use Color.Transparent if you wish to hide them
 *
 * @return true if separator set, false if field was not accessible
 */
public boolean setSeparatorColor(int separatorColor) {
    this.separatorColor = separatorColor;
    if (fieldPickerDivider == null) {
        Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                fieldPickerDivider = pf;
                break;
            }
        }
    }
    if (fieldPickerDivider != null) {
        try {
            fieldPickerDivider.set(this, new ColorDrawable(separatorColor));
        } catch (IllegalAccessException | IllegalArgumentException e) {
            return false;
        }
    } else {
        return false;
    }
    return true;
}
 
开发者ID:Commit451,项目名称:FitterNumberPicker,代码行数:30,代码来源:FitterNumberPicker.java

示例14: updateSelectorWheelPaint

import android.widget.NumberPicker; //导入依赖的package包/类
private boolean updateSelectorWheelPaint() {
    if (selectorWheelPaint == null) {
        try {
            Field selectorWheelPaintField = NumberPicker.class.getDeclaredField("mSelectorWheelPaint");
            selectorWheelPaintField.setAccessible(true);

            selectorWheelPaint = ((Paint) selectorWheelPaintField.get(this));
        } catch (Exception e) {
            return false;
        }
    }
    if (selectorWheelPaint != null) {
        selectorWheelPaint.setColor(textColor);
        selectorWheelPaint.setTextSize(textSize);
        invalidate();
        return true;
    }
    return false;
}
 
开发者ID:Commit451,项目名称:FitterNumberPicker,代码行数:20,代码来源:FitterNumberPicker.java

示例15: SubtitleDelayTVPicker

import android.widget.NumberPicker; //导入依赖的package包/类
public SubtitleDelayTVPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    mContext=context;
    slaveView=null;
    final NumberPicker.Formatter twoDigitFormatter = new NumberPicker.Formatter() {
        final StringBuilder mBuilder = new StringBuilder();
        final java.util.Formatter mFmt = new java.util.Formatter(mBuilder, java.util.Locale.US);
        final Object[] mArgs = new Object[1];
        public String format(int value) {
            mArgs[0] = value;
            mBuilder.delete(0, mBuilder.length());
            mFmt.format("%02d", mArgs);
            return mFmt.toString();
        }
    };

   
    init();
    if (!isEnabled()) {
        setEnabled(false);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:23,代码来源:SubtitleDelayTVPicker.java


注:本文中的android.widget.NumberPicker类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。