Android date pick field following guidelines - android

Following Android's design guidelines, I ran into this part https://developer.android.com/design/style/metrics-grids.html, where they use a view that I believe is a Spinner in order to show and possibly select the date.
Please guide me in the right directions as I'm not 100% sure this is a Spinner, and also, checking the Calendar app, it seems once you click on it, a DialogFragment pops up, with a single DatePicker (or TimePicker for the hours), but I am not 100% sure of this either.
Thanks in advance

Take a look at the docs, you can specify the Spinner mode. Whether you choose to make it a dialog or dropdown is up to you. Either way, you don't have to worry about setting the value after user has selected it.
http://developer.android.com/reference/android/widget/Spinner.html#MODE_DIALOG

Related

How to enable setCalendarViewShown or disable calendar in datepicker post API 24

I have a project where I use datepicker for the user to confirm a date
When the user selects confirm I wish to disable the datepicker so that they can't use it again
Unfortunatelly when I do something like this:
((DatePicker)findViewById(R.id.datepicker)).enabled = false;
only the spinner part gets disabled while the calendar can still be touched and used to alter the spinner
the only solution I found is using setCalendarViewShown(false) when the user confirms and then disabling the picker
unfortunatelly this seems to be deprecated so I wish to find some way to replace it
So my question is this
Is there a way to programmatically either disable ALL parts of the DatePicker or hide the calendar?
I know it can be done through xml but I wish to use it in code
Thanks in advance for any help you can provide
You can hide the datepicker with:
datepicker.setVisibility(View.INVISIBLE);
An option that you can choose to disabled all dates less one, is combine this two lines.
datepicker.setMinDate
datepicker.setMaxDate
So after the user pick one date, set the date like the min and the max of the calendar, and with this way, the user will not be able to choose a new one.
Something like:
datepicker.setMinDate(theDatePickedByUser)
datepicker.setMaxDate(theDatePickedByUser)
It should work...

What is the right UI pattern for an optional date?

I am using a DialogFragment to show a DatePicker to choose a date. The point is that such date could be optional, so somewhere i should display a checkbox asking to use the date or not. So how would you do such an UI ?.
So far i tried adding a checkbox on the same DialogFragment but i believe the interaction wont be very intuitive because if you choose the checkbox "no date" i would have to block or disable the datepicker but i wasn't able to do that and even if i do i am not sure if it is the best approach.
Have you seen any application solving a problem like this and how does it solve it ?
Here's how I solved it in my app: make it clear on the button that launches the DialogFragment that a date is optional.
After a date is chosen, add the option to remove it. Clicking on the "x" restores the button to look like above.

How to use a spinner that does not expand, but just used to click on?

I am getting this from googles calendar, hopefully you can see the image:
When looking specifically at the From and To parts, those look like Spinners, but I could be completely wrong. I would like to do that, essentially what the Calendar in ICS does with Spinners. I put the users date in it, then user clicks and a datepicker pops up. Problem is, I dont see anything that allows me to just set text in it. How can I set it to text without expanding? Thanks in advance.
They don't use a Spinner, but a Button that looks like a Spinner. Take a look to the style.xml files of the app.

Looking for Android number picker (10-key style)

I am looking around for a number picker in a 10-key style, ideally as a dialog... but called as an activity is fine too. I want to offer the user an interface that is a little more directed toward entering $ for an invoice amount field. I have seen adjustments to the date and time pickers but they looked awkward for this application. I have also seem someone call the built-in calculator, which would be fine, but I don't know how they were capturing a returned value (if they were). Any ideas? Yes, I can fall back to a regular edit field and the standard android keyboard... I was just hoping for something a little more slick. Thanks!
Have you tried setting the attribute android:numeric on the TextView?
TextView documentation

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