Sunday, 15 August 2010

Set alarm according to timepicker in android -



Set alarm according to timepicker in android -

i want app sets alarm according time-picker , not data-picker, want alarm go off every day @ time time-picker set at.

i don't want have button becomes picker want utilize time-picker icon.

if want have button without text, can utilize

<imagebutton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/button_icon" ... />

if want set alarm create new class, shows timepicker in fragmentdialog

public static class timepickerfragment extends dialogfragment implements timepickerdialog.ontimesetlistener { @override public dialog oncreatedialog(bundle savedinstancestate) { // utilize current time default values picker final calendar c = calendar.getinstance(); int hr = c.get(calendar.hour_of_day); int min = c.get(calendar.minute); // create new instance of timepickerdialog , homecoming homecoming new timepickerdialog(getactivity(), this, hour, minute, dateformat.is24hourformat(getactivity())); } public void ontimeset(timepicker view, int hourofday, int minute) { // here selected time, whatever want } }

and in activity, button:

<button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/pick_time" android:onclick="showtimepickerdialog" />

set onclicklistener, starts fragmentdialog timepicker

public void showtimepickerdialog(view v) { dialogfragment newfragment = new timepickerfragment(); newfragment.show(getsupportfragmentmanager(), "timepicker"); }

http://developer.android.com/guide/topics/ui/controls/pickers.html#timepicker

i dont understand, asking for. clarify question please.

android alarm timepicker

No comments:

Post a Comment