Make custom listview dialog look like standard dialog listview - android

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

Related

Android Spinner with "Radio Buttons" and Cancel button

I am looking for some guidance on how to develop the following spinner dialog shown below in the screen shot. It is present in your your android phone's Settings->Display-> Font Size option.
I have been able to implement a spinner with a simple CheckedTextView for each row.
But I am looking to develop something more specific as shown below.
I have searched all over the place for custom spinners.. but most of the show me how to add images etc to each item in the dropdown.. but nothing specific like this... where I have to "pre select" an item based on what is already chosen.
Some questions I am grappling with are....
1) Are those simple radio buttons beside a text view?
2) How would I know which item to "set selected" when I open the spinner dialog? Because my code would reside in my adapter, where my spinner would be in my Activity/Fragment.
3) How would I put a cancal button in a spinner dialog which dismisses it?
Thanks.
I had created a custom DialogFragment and inside onCreateDialog i am creating AlertDialog and showing it.
use these as reference links
http://developer.android.com/reference/android/app/DialogFragment.html
http://www.cs.dartmouth.edu/~campbell/cs65/lecture13/lecture13.html

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

Custom theme for spinner dialog

I would like to customize the appearance of the dialog that appears when I click on the spinner in spinnermode=dialog.
I want to use a dialog fragment but I find no documentation.
Is it possible?
No. The appearance is fixed to give it the feel of the operating system. You would have to create your own spinner to do this which isn't easy but also not too difficult if the lists in your spinner won't get so large that it takes up all the phone's memory. Just make a control that can scroll vertically.

popup windows in android?

Pretty new to android so excuse me if this is a really obvious question.
Say my application has a bunch of TextViews, each one showing the attributes of a certain product (name, price, etc). I have a button next to each of these TextViews labeled "modify".
How do I make it so that when I press the modify button next to a certain attribute, a popup window with a space to enter text into comes up so that the user can enter text into this box and then have the actual attribute listing on the original page change? Actually I just need a push in the right direction with creating this popup text field... not sure if there is already some built in functionality for this or if not, what would be the best way to create this kind of thing.
Thanks.
Why not have the modify button set TextEdit.setEnabled(true); and then change focus with TextEdit.setFocus? Note that both of these are inherited from view
If you really want a dialog you might want to looking into the AlertDialog.Builder. I know you can use it with buttons and radio buttons, but I'm not sure you can get it to work with a TextView.
Use a code like this for the input popup: Android dialog input text
In the positive button handler, set your edittext content programmatically like this:
myEditText.setText(value).
As simple as that. The only difference with a standard GUI framework is that you don't retrieve the value as a result of the popup function. Instead, you must provide an action handler.

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.

Categories

Resources