Create dialog like DatePicker - android

I need to do a dialog like DatePicker or TimePicker, but the dialogue should display my data. Is this possible, or do I need to do a custom view for this?

Sorry, but I can't comment because I don't have enough rep.
There isn't a ready out of the box dialog that allows custom data to be set. I supposed the best approach would be to create a custom layout with a NumberPicker and then set it as your dialog's view.
This answer should point you to right direction.

Related

Can OnLongClickListener for Android be used in an AlertDialog?

I have a list of options that are shown in an AlertDialog. The AlertDialog populates the list from a SharedPreferences file. Currently the user makes a selection, the AlertDialog closes and depending on the choice some edit text fields are filled in.
I would like to add an OnLongClickListener call to each option in the list, which when utilized would pop up another AlertDialog, over the top of the existing one, with a simple "are you sure you want to delete this?" question, then a yes and no button.
The dialog creation is simple, I just want to know if the OnLongClickListener can be applied and if AlertDialogs can be down on top of each other?
my answer here may help with adding an OnLongClickListener. The code I added is at the bottom of my response.
You can accomplish what you want by setting a new OnShowListener on your dialog and overriding the onShow() method

Make custom listview dialog look like standard dialog listview

I have a dialog with a listview, the first dialog is for selecting an item and the second one is when you edit the dialog. The first one uses a standard dialog box with no custom layout but for the second one I had to use a custom layout to get the picture in place (if anyone knows how I can populate a standard multiple choice dialog with an typed arrayadapter and item template let me know :)). The first dialog looks like standard dialog should look like but how can I get the second one to look the same with white background, lines between the items etc and be sure it always looks like the standard one even when that one is changed.
Standard
(source: filedump.net)
Custom
(source: filedump.net)
/Viktor
For the same, you need to use setMultiChoiceItems while creating dialog. I hope this example helps you: Android Multi selection dialogs
And also check this example: Android: Spinner-Like UI for Selecting Multiple Options

How to customize the styling of the radio buttons in an AlertDialog.Builder?

I'm wondering if there's a way to customize the look of the radio buttons in an AlertDialog.Builder? I have a selector XML file that works great for my custom radio button images, but I don't know how to assign it to an AlertDialog.Builder. Is it possible, or do I maybe need to create a completely custom Dialog? Any help/advice would be appreciated, thanks!
you can set a custom layout to your alert dialog which will contain your custom radio buttons (maybe a static number or a listview of items containing radio buttons depending on what you need) but it is surely possible.
Me personally if your view has even a bit more functionality than the default and you can see its future getting more and more customized and extended, i always make a custom dialog extending the Dialog class. its about the same amount of work but can go a long way in improving and adding features.
Hope this helps.

Android dialog or floating activity off-center

Is it possible to have an Android Alert box or Dialog off-center? I have tried everything that comes to mind, including making a custom Dialog activity and theme (extending Android:Theme.Dialog), but I have not been able to move it from it's centered position.
Yes you can make the background translucent and fill the entire view, then nest a visible layout within that you can use layout_gravity="top|left" on.
A little off topic, but if you just want to display text, an easier way is to use a toast.
Toast toast = new Toast(new ContextThemeWrapper(getApplicationContext(), R.style.YourDialogStyle));
toast.setGravity(Gravity.LEFT|Gravity.TOP, 0,0);
PopupWindow? An example can be found here: http://www.anddev.org/how_to_create_a_popupwindow-t1259.html

Is this a standard AlertDialog or is it custom?

I'm looking to replicate and improve upon the following AlertDialog in my app:
http://i.stack.imgur.com/aU3Ep.png
Is this a built-in AlertDialog, or was this made from scratch? If it was made from scratch, what control/widget is the number picker? Or is that built from scratch too?
Thanks!
btw.. screenshot is from Math Alarm Clock Pro
Looks like custom dialog made like explained here: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Kind of looks similar to this one:
http://www.quietlycoding.com/?p=5
So that would mean: custom made.
You find some interesting links if you search on google for "android NumberPicker"
Built in Dialogs are AlertDialog, DatePickerDialog, ProgressDialog, TimePickerDialog (see developer.android.com/reference/android/app/AlertDialog.html )
This explains the default AlertDialogs: http://developer.android.com/guide/topics/ui/dialogs.html
But there is one interesting function in AlertDialog (setView(...)) you could use to make the above (but you have to create the view by yourself - edittext and two buttons plus okay button - and assign the onclickevents). See the function here: http://developer.android.com/reference/android/app/AlertDialog.html#setView(android.view.View)
Just looks like a standard dialog set to have no title. It then has an EditText sandwiched between two buttons with a confirmation button at the bottom.
Edit: Here is an abridged snippet from my onCreateDialog override in an app of mine.
Dialog dialog;
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

Categories

Resources