I am trying to implement an activity where I want the user to put a date information.
I would like it to look like the Android Calendar App. Their button looks like a spinner, but with the selected date (picture 1). When the button is clicked, it opens the Date Picker dialog (picture 2).
http://pineapple.cc/datepicker1.png
http://pineapple.cc/datepicker2.png
Should I use a redesigned button, spinner, textview ?
Thank you a lot for you help
Does the supplied widget not do it for you? Ooops misunderstood question. Disregard.
Edit:
I'm looking at the EditEventView activity in the Calendar app, and they're using a button that launches the DatePicker widget. The setDate() method there does the formatting.
Related
I'm using a CalendarView on my activity, that shows some events on selected date. If an event is clicked, a new activity is started and showing some details of the event. Everything works fine. But if I go back to previous activity, 'today' is selected (it's my default). Is it possible to go back to the date of the event I selected?
Thanks a lot for your help!
Do the one thing when you select date at that time store that date into static variable or anywhere and when you came back to that activity set that day,month and year to that date picker dialog that way you can achieve what you want.
My app is supposed to have a Datepicker. To invoke the date picker fragment a button is pressed and then the floating date picker appears.
My problem is that the button does not look similar to the rest of the UI components being used to accept data. Is there any way I can make the button look and function like the one in Google calendar app?? The date picker button dynamically displays the date chosen too and would like to have that functionality too.
Picks for reference:
My current button:
The type of button I want to achieve:
I looked around a bit and was able to change the look by putting the following code in the xml code:
style="#android:style/Widget.DeviceDefault.Light.Spinner"
Here is how to add text to the button.
I am currently developing a reservation system application that would require the user to input date and time.
So that would mean that I would have a date picker and a time picker in mu layout file.
Upon doing so, when a user clicks the button to set Date and time of reservation the app will then start an Intent and opens another activity but as far as I see it, It would look awful if I do such so I was wonder how to do this kind of UI so that it would not be as hassle as to start and activity for a result.
You have a number of options to implement this behavior.
The official date picker dialog and time picker dialog.
Given that the use of dialogs is discouraged, try using the widgets inline with CalendarView and DatePicker if you can.
A backported version of the widgets CalendarView and DatePicker.
For my application, I have to get a date from the user.
I have try a simple EditText with the input type to date, but it's not very convenient for the user who has to enter himself the '/' character.
I have also tried the DatePicker component. It's more convenient than the EditText but it is big compared to others components like EditText.
Is there a best way for a user to get a date ?
Have a button that displays the date and when clicked shows a DatePickerDialog.
I would go with DatePickerDialog that is triggered by "Change" button next to TextView field with currently selected date.
So did you not want to use DatePicker? I'm a bit confused by your problem, since there isn't necessarily a "best" way to get a date, it's based on your preference and situation. If you would like an alternate way to get a date, you could have 3 separate EditText Views that take in the Month, Day and Year and get that information with a "submit" Button or something of that nature. Or you could look into Spinners. Here's and example.
For keyboard entry I normally prefer a maskedit box. If the interface is for touch or mouse you might want to include a drop down calendar.
i have some problems in using the date picker from xml layout.
in my app when the user clicks a text view a custom dialog box opens. In the layout of the custom dialog box i am showing a date picker which i have place in my xml file. When it appears in the app i want a particular date to be viewed, for example as 01 Jan 1950. Every time it opens it is showing the present date only.
In my dialog box i have a set and cancel buttons. The Cancel button cancels the dialog box where as when i click the Set button i want the current date to be stored to a String.
In another activity of my app in a custom dialog box i want to show a date picker only with the year columns, i dont need the date and month columns. How to get it, please help me friends
Without seeing any code, I just can propose you to use the method init from the DatePicker class. Check this link but basically, in your activity do something like:
myDatePicker = (DatePicker)findViewByID(...);
myDatePicker.init(myYear,myMonth,myDay, myOnDateChangedListener);