numberpicker

Android NumberPicker with strings

六眼飞鱼酱① 提交于 2019-12-04 05:32:42
问题 I have customised the NumberPicker to show text. The output is this: when I press OK I want to add the e.x mouse to my list "Article". What I'm getting instead is the index value (int). Its populated by "array[]", it includes a list with the data shown. What's the workaround to get my item/string.? public void Generatortable(){ final android.support.v7.app.AlertDialog.Builder alert = new android.support.v7.app.AlertDialog.Builder(this); alert.setCancelable(false); LinearLayout l1 = new

Catch keyboard 'Done' for NumberPicker

半城伤御伤魂 提交于 2019-12-04 03:16:18
I have an AlertDialog with just some text, a NumberPicker , an OK, and a Cancel. package org.dyndns.schep.example; import android.os.Bundler; import android.view.View; import android.widget.NumberPicker; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.content.DialogInterface; public class FooFragment extends DialogFragment { @Override public void onAttach(Activity activity) { super.onAttach(activity); mParent = (MainActivity) activity; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) {

How do you display a 2 digit NumberPicker in android?

痞子三分冷 提交于 2019-12-04 00:18:11
I want to create a timer and since I couldn't create a digital interface that is editable for the user to set the time I want to use the NumberPicker. However the NumberPicker only displays 1 digit for the numbers between 0-9. How do you format the picker so that it will display two digits such as 01 02 03 and so forth. numberPicker.setMaxValue(10); numberPicker.setMinValue(0); numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int i) { return String.format("%02d", i); } }); This will do the trick! Implement a custom NumberPicker.Formatter that implements

android numberpicker for floating point numbers

最后都变了- 提交于 2019-12-03 04:06:40
The user of our app should be able to adjust a floating point number. At the moment, I filled an ArrayAdapter with all possible values and attached it to a spinner. This solution doesn't really meet our expectations, since the spinner dropdown box is way too tall. Is there a better way? I was looking at Numberpicker - but this seems to work only with Integer values. Any ideas? Thanks! Zombie NumberPicker is not just for integers.. Even you can use Floats String etc. see this and read about it. for tutorials : http://gafurbabu.wordpress.com/2012/03/29/android-number-picker-dialog/ And I had

Android NumberPicker with strings

不打扰是莪最后的温柔 提交于 2019-12-02 06:16:32
I have customised the NumberPicker to show text. The output is this: when I press OK I want to add the e.x mouse to my list "Article". What I'm getting instead is the index value (int). Its populated by "array[]", it includes a list with the data shown. What's the workaround to get my item/string.? public void Generatortable(){ final android.support.v7.app.AlertDialog.Builder alert = new android.support.v7.app.AlertDialog.Builder(this); alert.setCancelable(false); LinearLayout l1 = new LinearLayout(getApplicationContext()); l1.setOrientation(LinearLayout.HORIZONTAL); final NumberPicker

NumberPicker showing wrong value after setValue()

醉酒当歌 提交于 2019-12-02 02:39:58
I was trying to create a NumberPicker that would meet my needs, but I stumbled upon something and I don't understand what it is. The behavior is simple, I have three number pickers and each one of them can have a value from -15 to 15; when the user presses the Ok button the values selected, if valid, are saved in a "structure" and in a SharedPreferences for convenience. The problem is shown in this screenshot . When I save a number that is not -1 it works without problems. If I save a -1 the result is the one above (it happens in every number picker). Even though is displayed a -15 the actual

Getting float/double from NumberPicker

六月ゝ 毕业季﹏ 提交于 2019-12-02 02:15:47
问题 I am trying the https://github.com/SimonVT/android-numberpicker library and the reference is https://developer.android.com/reference/android/widget/NumberPicker.html#getValue%28%29 Now both, the API level 11 NumberPicker returns int value in getValue method and also the SimonVT numberpicker returns int value. But I had set double values in the number picker by using following code: String[] nums = {"1","1.5","2","2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9"}; final

Getting float/double from NumberPicker

旧城冷巷雨未停 提交于 2019-12-02 00:55:28
I am trying the https://github.com/SimonVT/android-numberpicker library and the reference is https://developer.android.com/reference/android/widget/NumberPicker.html#getValue%28%29 Now both, the API level 11 NumberPicker returns int value in getValue method and also the SimonVT numberpicker returns int value. But I had set double values in the number picker by using following code: String[] nums = {"1","1.5","2","2.5","3","3.5","4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9"}; final NumberPicker listeningScorenp = (NumberPicker) findViewById(R.id.listeningScore); listeningScorenp

How to setOnValueChangedListener from NumberPicker inside a BaseAdapter

别来无恙 提交于 2019-12-01 14:27:32
I am trying to create a BaseAdapter which each element has a NumberPicker and a Button. The button's action parameters depends on the value picked in NumberPicker. One solution I thought was creating a setOnClickListener (of the button) inside the onValueChange of the NumberPicker, the problem is onValueChange never gets fired when I change the number. I leave you the code to make it clearer: public class Adapter extends BaseAdapter{ ... public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) con

Android NumberPicker OnValueChangeListener

自作多情 提交于 2019-12-01 13:02:38
I have a question concerning the Android NumberPicker . When the user is performing a Fling on a NumberPicker , for every single step the Listener for OnValueChange is triggered. Can I change this in that way, that the oldVal and the newVal can possibly differ by more than 1 from each other and the Listener is only triggered once? Thanks in advance. EDIT: I will try to explain it more specific in my code. int diff = Math.abs(newVal - oldVal); if (newVal - oldVal > 0) { sendMessage(te); for (int i = 0; i < diff; i++) { sendMessage(plus); } sendMessage(te); } else if (newVal - oldVal < 0) {