use of android.widget.NumberPicker in project wire-android by wireapp.
the class EphemeralLayout method onFinishInflate.
@Override
protected void onFinishInflate() {
super.onFinishInflate();
ContextThemeWrapper cw = new ContextThemeWrapper(getContext(), com.waz.zclient.ui.R.style.NumberPickerText);
numberPicker = new NumberPicker(cw);
numberPicker.setMinValue(0);
final EphemeralExpiration[] ephemeralExpirationsValues = getAvailableEphemeralExpirations();
numberPicker.setMaxValue(ephemeralExpirationsValues.length - 1);
String[] values = new String[ephemeralExpirationsValues.length];
for (int i = 0; i < values.length; i++) {
values[i] = getDisplayName(ephemeralExpirationsValues[i]);
}
numberPicker.setDisplayedValues(values);
numberPicker.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (callback != null) {
callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], true);
}
}
});
numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
if (callback != null) {
callback.onEphemeralExpirationSelected(ephemeralExpirationsValues[numberPicker.getValue()], false);
}
}
});
try {
//NoSuchFieldException
Field f = numberPicker.getClass().getDeclaredField("mSelectionDivider");
f.setAccessible(true);
f.set(numberPicker, getResources().getDrawable(com.waz.zclient.ui.R.drawable.number_picker_divider));
} catch (Throwable t) {
Timber.e(t, "Something went wrong");
}
addView(numberPicker);
}
use of android.widget.NumberPicker in project Talon-for-Twitter by klinker24.
the class ConfigurePagerActivity method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
case R.id.menu_select_number_of_pages:
final NumberPicker picker = new NumberPicker(context);
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
picker.setLayoutParams(params);
picker.setMaxValue(TimelinePagerAdapter.MAX_EXTRA_PAGES);
picker.setMinValue(0);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.menu_number_of_pages);
builder.setView(picker);
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
sharedPrefs.edit().putInt("number_of_extra_pages", picker.getValue()).commit();
dialog.dismiss();
recreate();
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
return true;
default:
return true;
}
}
use of android.widget.NumberPicker in project material-calendarview by prolificinteractive.
the class DynamicSettersActivity method onTileWidthHeightClicked.
@OnClick(R.id.button_set_width_height)
void onTileWidthHeightClicked() {
final LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.HORIZONTAL);
final NumberPicker pickerWidth = new NumberPicker(this);
pickerWidth.setMinValue(24);
pickerWidth.setMaxValue(64);
pickerWidth.setWrapSelectorWheel(false);
pickerWidth.setValue(currentTileWidth);
final NumberPicker pickerHeight = new NumberPicker(this);
pickerHeight.setMinValue(24);
pickerHeight.setMaxValue(64);
pickerHeight.setWrapSelectorWheel(false);
pickerHeight.setValue(currentTileHeight);
layout.addView(pickerWidth);
layout.addView(pickerHeight);
new AlertDialog.Builder(this).setView(layout).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(@NonNull DialogInterface dialog, int which) {
currentTileWidth = pickerWidth.getValue();
currentTileHeight = pickerHeight.getValue();
widget.setTileSize(-1);
widget.setTileWidthDp(currentTileWidth);
widget.setTileHeightDp(currentTileHeight);
}
}).show();
}
use of android.widget.NumberPicker in project material-calendarview by prolificinteractive.
the class DynamicSettersActivity method onTileSizeClicked.
@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();
}
Aggregations