Posts

Showing posts with the label Numberpicker

Android Numberpicker For Floating Point Numbers

Answer : 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 used NumberPicker long ago like this and it might be some use posting here: NumberPicker np; String nums[]= {"Select Fraction","1/64","1/32","3/64","1/16","5/64","3/32","7/64","1/8","9/64","5/32","11/64","3/16","13/64","7/32","15/64","1/4","17/64","9/32","19/64","5/16","21/64","11/32","23/64","3/8","25/64","13/32","27/64","7/16","29/64"}; np = (NumberPicker) findViewById(R.id.np); np.setMaxValue(nums.length-1); np.setMin...

Android PreferenceActivity Dialog With Number Picker

Answer : Subclass DialogPreference to build your own NumberPickerPreference . I have implemented one below for you. It works perfectly fine, but is not feature complete. For example the minimum and maximum values are hard-coded constants. These should really be attributes on the preference xml declaration. To get that to work you would need to add an attrs.xml file specifying your custom attributes. For the full implementation of the NumberPicker preference widget that supports custom xml attributes in a library project and a demo app showing how to use it, see GitHub: https://github.com/Alobar/AndroidPreferenceTest You would use the widget as any other preference widget, except you have to fully qualify the name: preferences.xml <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <com.example.preference.NumberPickerPreference android:key="key_number" android:title="Give me a number" ...