Android: Date Picker using xml layout - android

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);

Related

I want to display date picker, start time and end time will come in one screen?

i want to implement date picker, start time and end time picker in one screen.
and my screen show look like my image should be like
with two time pickers
follow below steps
create separate fragment screen
show separate custom date picker view for start and end date
show custom time picker below to date picker for start and end time.

Make a Datepicker button look similar to the one in Google calendar app

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.

What User Interface Design or Layout is this

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.

Build a number selector dialog with AlertDialog (similar to DatePickerDialog)

With the DatePickerDialog we can have a fancy interface to set the date as this
(source: androidpeople.com)
I like it but it can only be used to set date so how could I build a "DatePickerDialog-like" AlertDialog?
I mean users could click on the "plus" and "minus" button as well as put in the number with keyboard.
Instead of only being able to select a single date, I'd be able to select three different numbers using the three up/down/scroll controls.
Alright, here you go, check this out. Then, check out Android Custom Dialogs, which would allow you to make your own custom dialog.
Check out this project for more information
Make an EditText field that they can edit with a button to the right which says Pick a Date and pops up a dialog. If the user selects the popup dialog, fill in the EditText with the result.
You can make a custom view with a "+" button, an edittext and a "-" button. Make a custom dialog with that view. Read about Android Custom Dialog. I hope I helped.

Android: timepicker and datepicker in the same dialog box

I am developing an app for android. I have created a timepickerdialog and a datepickerdialog, but the problem is, both of them run in different dialog boxes, which is not what the way I want my app to work :-S
Is there any way to create a single dialogbox with both time and date picker dialog boxes in it together?
Thx
You can find a DateTimePicker implementation here:
http://code.google.com/p/datetimepicker/
I have created a custom Alert Dialog as in the Google tutorial. I replaced the ImageView and the TextView with a DatePicker and a TimePicker. I changed the following line:
View layout = inflater.inflate(R.layout.custom_dialog,
(ViewGroup) findViewById(R.id.layout_root));
with this:
View layout = inflater.inflate(R.layout.dialog_date_time,
(ViewGroup) findViewById(R.id.datePicker));
For whatever reason the first gave an error, but the second worked. Anyway, I can use the two views in the same dialog window now.
call time picker dialog in datepicker's update time method,It'll not be called at the same time but when you press datepicker's set button,Time picker dialog will open . The method is given in the answer of this link:
DateTime picker in android application

Categories

Resources