android-number-picker

Call requires API level 29 (current min is 21): `android.widget.NumberPicker#setTextColor`

我与影子孤独终老i 提交于 2021-01-04 05:31:24
问题 I want to change selected field of text color using setTextColor. But Android Studio gives me this error. What should I do? Min SDK is 21. This is code of my CustomNumberPicker class: import android.annotation.TargetApi import android.content.Context import android.graphics.Color import android.graphics.Paint import android.graphics.Typeface import android.graphics.drawable.Drawable import android.os.Build import android.os.Build.VERSION import android.os.Build.VERSION_CODES import android

Formatted value of NumberPicker disappears onClick

心不动则不痛 提交于 2020-01-04 09:17:45
问题 My NumberPicker in setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS) mode and the setWrapSelectorWheel(false) is turned off. I formatted my Numberpicker with a simple formatter: mNumberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { return TextUtils.makeQuatityString(getContext(), value, R.plurals.nWeek); } }); Example output: 4 Weeks, where 4 is the value. The NumberPicker is in a Dialog and after a short click on the value, the "Weeks"

How to hide the previous and next numbers in a number picker?

故事扮演 提交于 2019-12-30 11:53:08
问题 Summary I'm attempting to hide the previous and next numbers in an Android number picker. Additionally, I'm extending the NumberPicker class so that I can change the font size and color. I've noticed that I could potentially change the value: private static final int MODIFIED_SELECTOR_WHEEL_ITEM_COUNT = 3; I'm just not sure how I could override a static final value. Default number picker: Desired Modified Number Picker I would like to make the number picker look like so, with the animation in

Passing number from 1st activity to the number picker

限于喜欢 提交于 2019-12-20 06:25:12
问题 This is my 1st activity public void onClick(View v) { switch (v.getId()) { case R.id.setButton: int cpv= carbPValue; int ppv = proteinPValue; int fpv=fatPValue; Intent intent = new Intent ( this, AdjustMacronutrients.class ); intent.putExtra ( "carbP", cpv ); intent.putExtra ( "proteinP", ppv ); intent.putExtra ( "fatP", fpv ); startActivity(intent); finish(); } } This is my 2nd activity : I have 3 integer value pass from 1st activity which is cpv , ppv , fpv . How can i set those value

Create a number picker in horizontal mode, did android:orientation=“horizontal” work? I have try but the number picker still same in vertical mode [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-19 11:16:20
问题 This question already has answers here : Is it possible to make a horizontal NumberPicker? (5 answers) Closed 4 years ago . I want to create a number picker in horizontal mode, but i set the android:orientation="horizontal", it still cannot work. How can i create the number picker in horizontal mode just like the pic below ? <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android

Display more numbers in NumberPicker

♀尐吖头ヾ 提交于 2019-12-12 19:42:08
问题 I have two issues, first one is removing the divider in the NumberPicker and I'm extending the NumberPicker in Android to solve this issue, like this: import android.content.Context; import android.content.res.Resources; import android.util.AttributeSet; import android.widget.NumberPicker; import java.lang.reflect.Field; public class ExtendedNumberPicker extends NumberPicker { public ExtendedNumberPicker(Context context, AttributeSet attrs) { super(context, attrs); Class<?> numberPickerClass

How to decrease padding in NumberPicker

不想你离开。 提交于 2019-12-10 12:28:48
问题 How to decrease padding in NumberPicker I want something like it: 回答1: It's surprisingly easy to archive: ( scaleX and scaleY equals 2.5) (without scaleX and scaleY ) String[] values = {"Public", "Shared", "Private",....}; NumberPicker np= (NumberPicker) findViewById(R.id.numberPicker); np.setMaxValue(values.length-1); np.setMinValue(0); np.setDisplayedValues(values); And simply set small layout_height and scaleX , scaleX : <NumberPicker android:id="@+id/numberPicker" android:layout_width=

How to get value of the NumberPicker instance from onValueChange when The NumberPicker not scrolling only(pressing plus or minus buttons) in Android

烈酒焚心 提交于 2019-12-08 03:24:45
问题 I have a NumberPicker instance and it works as expected but I need to get value form it when scrolling stops Or when the user only press increments / decrements Button is pressed. the value that i should get it are displayed in the text view. i managed to get the value when scrolling stops/ became idle and displayed correctly(this done in onScrollChanged() listener). but the onScrollChanged() listener won't be fired when user press on increments or decrements buttons and if I use

How to customize value for numbers in NumberPicker in android?

寵の児 提交于 2019-12-07 21:56:32
问题 I have a number picker for setting a data limit in MB. right now, I have numberPicker, contains numeric values in sequence like [1,2,3,....., 2000 MB]. But I want a numberPicker that should contain numeric values like [100,200,300,...., 2000MB]. How can I do this? 回答1: Displayed array values for your picker int NUMBER_OF_VALUES = 20; //num of values in the picker int PICKER_RANGE = 100; ... String[] displayedValues = new String[NUMBER_OF_VALUES]; //Populate the array for(int i=0; i<NUMBER_OF

How to customize value for numbers in NumberPicker in android?

隐身守侯 提交于 2019-12-06 15:09:12
I have a number picker for setting a data limit in MB. right now, I have numberPicker, contains numeric values in sequence like [1,2,3,....., 2000 MB]. But I want a numberPicker that should contain numeric values like [100,200,300,...., 2000MB]. How can I do this? Saif Displayed array values for your picker int NUMBER_OF_VALUES = 20; //num of values in the picker int PICKER_RANGE = 100; ... String[] displayedValues = new String[NUMBER_OF_VALUES]; //Populate the array for(int i=0; i<NUMBER_OF_VALUES; i++) displayedValues[i] = String.valueOf(PICKER_RANGE * (i+1)); /* OR: if the array is easy to