How to disable minutes change in TimePickerDialog - android

Is need to allow only to change hours, how can it be done?
In simple TimePicker, i can set the TimePicker.OnTimeChangedListener interface, but this interface is not available in TimePickerDialog.

You can copy the source of the original Widget and its layout and include it in your own project as a "library" class. You will also need to update the source's references to R. With the layout you can show anything you'd like in regards to not having minutes being editable. Since this is homework be sure to correctly note that you're customizing widget from Android source library.

Use getCurrentHour() and setCurrentHour(), and set the minutes to 0.

The documentation doesn't show any way to do that, so I guess there is no such a way. You could subclass the TimePicker class and disable the minute picker yourself, somehow, but there is no reason to work so much.
However, you can set the value to 0 (TimePicker.setCurrentMinute(0)) and if the user changes it, just ignore. And you should inform the user that changing the minute doesn't matter, as you don't use it.

Related

Overriding Android Chronometer class

I want to override the android chronometer class. I want it to inflate a custom XML layout and to also have a quicker update interval.
I've found one that modifies the update interval from the default 1s to 0.1s on github.
But I want to do more and have imageViews or Buttons display the time instead of the default textView it uses. I haven't really done this before except for a recycle view, so some explanation would be nice.
My end goal is to have an efficient stopwatch with custom digits and display, like the one found on HTC one M7 in the default clock app or any Samsung phone. I also need it to run in its own Fragment and be able to handle orientation changes and the activities onPause() or onStop() without losing any time.
Would it be better to use Intent Service and a Results Reciever? if so how would i accomplish this?
Chronometer is good for certain extent, but instead of customizing it you can create your own custom layout and display the time based on your requirements using a handler which would be the best solution for your problem.Find the link below for example
http://www.shawnbe.com/index.php/tutorial/tutorial-3-a-simple-stopwatch-lets-add-the-code/

Hint or alert inside Android app

Apologies for the rough sketch.
Basically I want, the first time the user opens the app, is to draw their attention to a button and have some text like "You can click me for more information!" or something like that.
Does anyone know what this is called? Is there a name for this sort of thing - and can it be done in native Android or would I need a third party library? Thanks
I think what you are talking about is called ShowCase View
Example Library : https://github.com/amlcurran/ShowcaseView
Edit : Note there are other libraries too. You can check android-arsenal for more
I think you can do it on your own with android's relative layout and it's textbox, by inflating the container(Relative layout) whenever you want to show, in this case at the first time of the activity and hide it later.
Try to keep the boolean value in shared preference so that your activity knows about when to show dialogue, since you would have changed the value to true at first run it will obviously hides.
However for the first time experience try the code in the given link, proof read, track and build your own later
http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
Hope it helps.
You can design an overlay screen for first time instructions.This tutorial might help -http://www.christianpeeters.com/android-tutorials/android-tutorial-overlay-with-user-instructions/

How to customize which items TimePicker shows?

I've been programming in Android just for a week now, so my philosophy might be a bit rigged from other IDEs. I am used to Visual C#'s style of dealing with components - just drag it on the screen, then choose possible preferences in its menu. That however doesnt seem to work here.
My problem: I am trying to make a simple countdown clock, with the user choosing the time through the timePicker. But for that, I need a different style of it than the default. Rather than choosing the "real" possible time, I would like it to have just minutes and seconds, sorted incrementally, so the user can choose "48 min, 9 sec" and press ok. How is this possible?
Thanks
Well, the TimePicker is meant for picking actual times... not quantities of time. So you can't do so using the TimePicker provided in the public SDK. You'll have to make your own custom view instead.
To do this, one thing you might consider trying is making your custom View extend TimePicker. Perhaps you could then override the appropriate methods to reach the desired behavior. It will require a bit of sifting through the source code on your part, however. I'm not 100% sure if it is possible either, but it seems like it should.

How to embed calendar in monthly view inside our layout

I need to embed the native month-wise calendar with my xml layout, which will also contain some other components inside the layout.. it should also show all the calendar events shown for the specific month. Since i am a beginner in android, any source or example will be very useful !!
Thanks in Advance
In your case I think you have to use Datepicker, just go throgth this example
Haha, funny how I am currently doing just this. There is no built in view to do this, and even fewer examples of any specific code. You will need to build one from scratch. Luckily, Android does come built in with a class to help with the calculations that would otherwise be very annoying:
http://developer.android.com/reference/android/util/MonthDisplayHelper.html
What does this mean? Well you need to use your own code to build it out. If you have Java experience, should not be too bad just playing around with the dates and whatnot and add them into a table or grid layout (Layouts you should probably go with). As soon as you get the hang of it, then you can get into more complex features.
Try using a grid view and fill according to month array with date-time picker you can get a specific date and time each cell click you can show a list which would help user to make reminder or add note specific to that selected date.

How to access the +/- dialog to modify a number (like when setting the time)

If you pop open the clock application and set the alarm you get a nifty pop-up with the time that you can modify using + and - buttons. I'm wondering if there's that's a standard and, if so, if there's an easy way to access it so that it pops up when clicking on an element in a ListView?
This is not a standard view in Android, so you will have to make it yourself. :-)

Categories

Resources