Android Custom number picker issue - android

I am building a library with a NumberPicker and two buttons which controls the Up and Down of the number. I set the min and max to the NumberPicker with setMin, setMax, setValue and after that I set an ordered array in the setDisplayValues method.
I've built an example with the component isolated, and its working fine.
But when I try to use my component inside my app, the component doesn't work as expected. When the component is showed, the value limit is not the correct value. When I refresh the value, moving the picker, it sets to the proper value, and everything works fine. But the first time is not working as expected.
I tried to put the NumberPickerisolated in the app, an the result is the same. Any idea?
In the image where you see 14 down...there is suppose to be nothing. In the other 14 is suppose to be a 1. The max value for the picker is 14.

Related

MPAndroidChart Change Graph's Date Range

I have a date-based graph with x-axis as dates. By default, I populate the graph with a data set of past 6 months. I would like to change the graph to show:
Last one week,
Last one month,
Last 3 months etc.
I looked at the API documentation for modifying the viewport here: https://github.com/PhilJay/MPAndroidChart/wiki/Modifying-the-Viewport
And tried playing around with:
graph.setVisibleXRangeMaximum(100);
graph.moveViewToX(50);
graph.invalidate();
I tried various different parameters, but nothing happens when the above code is executed. My graph already has data filled and is displaying correctly.
Am I looking in the right direction for what I want to achieve? How can I debug my issue?
For those interested, I found the solution.
TL;DR: There is no in-built functionality to change the granularity of the data shown. You need to set the chart's data-set accordingly.
Here is the example from samples: https://github.com/PhilJay/MPAndroidChart/blob/master/MPChartExample/src/main/java/com/xxmassdeveloper/mpchartexample/LineChartTime.java

Remove NumberPicker arrows Android

Is there a way to remove the NumberPicker UP/DOWN arrows?
I googled but I wasn't able to find any method.. I have 2 devices one with android 4.2.2 and one with 4.0.3, in the first one the NumberPicker is scrollable and has no arrows while in the second one the NumberPicker isn't scrollable and has the up/down arrows
Quoted from the android documentation class overview:
In your older device you get this one.
If the current theme is derived from Theme the widget presents the current value as an editable input field with an increment button above and a decrement button below. Long pressing the buttons allows for a quick change of the current value. Tapping on the input field allows to type in a desired value.
Whereas what you desire is this flavour of the widget:
If the current theme is derived from Theme_Holo or Theme_Holo_Light the widget presents the current value as an editable input field with a lesser value above and a greater value below. Tapping on the lesser or greater value selects it by animating the number axis up or down to make the chosen value current. Flinging up or down allows for multiple increments or decrements of the current value. Long pressing on the lesser and greater values also allows for a quick change of the current value. Tapping on the current value allows to type in a desired value.
This would seem to be from a compatibility issue due to android version. Check what minimum version of android your Holo derived themes use in your app. It may be that the theme your older 4.* device is not accessing the same theme, but one that shares many similarities.
I think you should create your own number picker and inflate it.
You can follow this tutorial on inflating elements .

Android Hide TimePicker numbers?

Is there a way to hide these numbers? Im guessing there must be an attribute which once set to 'false' should to it.
Also, i've tried to use custom drawables for the the up/down arrow, but those seem to overlay on top of the numbers (ie,the numbers are still visible)
Note: I could make custom pickers where I use a textView in between two imageViews, but the default timePicker allows one to swipe up and scroll through numbers (so would prefer using the default)
Edit: Apparently the NumberPicker has different children in different versions of android(the emulator shows the up/bottom arrows, while on my Samsung Tab they return a nullpointerexception). Wow!
Instead of using a time picker you could try and use a number picker instead, this means that you can specifically set what you want to be in the picker.
Is there a way to hide these numbers?
No, sorry.
Im guessing there must be an attribute which once set to 'false' should to it.
Only if you fork TimePicker and add such an attribute yourself.

How to have this type of time picker in Android?

I am developing an application in which i want to show time picker to set a time for reminder. Right now I am able to show a time-picker using preference screen like this
<org.example.android.TimePreference
android:defaultValue="12:00"
android:key="check_time"
android:summary="Set your desired time for check"
android:title="Check time" />
TimePreference.java file is inherited from this TimePicker in PreferenceScreen link. But I want to show this on button click in particular activity and set it values in EditText or in TextView. I don't want to use preferences.
So, I want to make the layout of this screen like below image.
Please have a look at this tutorial . you will get the project over there .
http://www.zainodis.com/2011/05/android-custom-timepicker.html
have a look at this example number picker.. like this you can change it into for time picker.
Android Number Picker Dialog
My answer is depending on the API level you are working with.
API level < 11: You'll have to backport the NumberPicker by copying it's source in your project and modifying it to your needs
API level >= 11: You can use the standard implementation of the NumberPicker and extend it to your needs.

numeric choice field:How to let the user set a value by incrementing/decrementing the displayed value

I have a range say,1-100 and i want the user to select a value from this range.Ofcourse showing this with a spinner will be awful.I want to use the functionality of date widget,where we can pick a date by pressing a +/- sign,the longer the press ,higher the iteration speed.
I found numberpicker.java that has the code the date widget uses to get this functionality, but do i have to paste that entire code to achieve this functionality!
Here is a tutorial on how to pull out NumberPicker; I've followed it myself: http://www.quietlycoding.com/?p=5
I found numberpicker.java that has the
code the date widget uses to get this
functionality, but do i have to paste
that entire code to achieve this
functionality!
Unfortunately, yes, plus perhaps some resources as well (I have not looked at that code recently). I am not aware of anyone who has pulled that out to make a reusable component, and it is not a widget in the SDK.
Sorry!

Categories

Resources