Let's say I have TimePicker and I use my fingers to select hour. After I select hour, TimePicker changes layout to 'select minutes'. How do I tell TimePicker, from code, that I want to select hour and not minutes?
Ok, I think I wasn't clear.
When we open TimePicker we select hour(first) and then minutes(second)
We can correct our choice by clicking on hour and minutes TextViews.
How can I change from minutes to hours from code?
Something like:
setHourSelectionLayout();
setMinuteSelectionLayout();
For this type of case, use a NumberPicker and keep the minutes constant or dummy set on the TextView/EditText. It will work out for the best
Related
I have a record with date and time, and I would want to convert the transaction date from current date, differentiate and show number of days.
For e.g.
If the the record has got a date time, which is 1 hours before than Now, the system should show an hour ago...
Similarly if there is a record with 3 days before then instead of showing a date, I would want to show "3 days ago".
No need to use any custom solution.
You can use android.text.format.DateUtils.getRelativeTimeSpanString
It returns a string describing 'time' as a time relative to 'now'.
reference: http://developer.android.com/reference/android/text/format/DateUtils.html
I need a custom date picker like this. But I need to select a period of time in my date picker.
for example I want: user open the date picker dialog, then select start day, then select end day (days between this 2 days are highlighted) then close the date picker dialog.
is there any open source library which i can use for this scenario?
or is there any way to edit this date picker to achieve this ?
I will appreciate any help.
Thank you
You can use android times square
this widget supports date ranges, but not have the same look and feel
The default Android Time Picker, have a step of 1 for minute. I want to change it to a step of 5 minutes. so by clicking on the "+" button, the time 09:20 become 09:25.
Is there an easy way to do it ?
You have to write your own TimePicker. I'm not sure if you can extend the existing TimePicker and handle the button events on your own. Here is more detailed answer for your question:
Android - TimePicker minutes to 15
Which android widget will be appropriate to get a duration time (hours and minutes) defined by a user? I think about a TimePicker, but it looks that it was created to get a time of a day.
Are there any other standard possibility, or I should write it from scratch?
I think you can use the TimePicker by customizing the time that you give to the TimePickerDialog.
The idea is to get the input defines by the user, format it and pass it to TimePickerDialog
I am basically using a datetime control in my application.
Wherein on a click event i am initiating datetime dialog.
In another scenario, i want to move current date, to next day, or previous day.
I don't want the dialogbox of date time control to be displayed.
Is it possible??
The DatePicker and TimePicker controls are available as widgets for you to use in your layouts or code.
You can then build the next day / previous day functionality yourself by setting the date / time of those controls.