Dialog

Put your problem here if it does not fit any of the other categories.

Dialog

Postby Marbert » Sun Feb 12, 2012 9:33 pm

I'm looking for a dialog and found this on the official Android-page: http://developer.android.com/guide/topi ... alogs.html

But I want a dialog where the user can enter text (for example: if you download something with your browser you can type in the name of the file you want to save). I want to have such a window, but cannot find it.

Can you help me? :)
Marbert
Developer
Developer
 
Posts: 30
Joined: Sat Feb 04, 2012 7:31 pm

Top

Re: Dialog

Postby Phyll » Sun Feb 12, 2012 11:44 pm

Hi Marbert,

You can make an activity that has the layout you want, then add the dialog style like this:

android:theme="@android:style/Theme.Dialog"

in the manifest. You can do pretty much anything you like in this activity. Use an intent to start it (you can send extras to preload it). Use startActivityForResult(Intent, requestcode) and receive the result back by overriding onActivityResult().

I'll send up a project with a dialog made this way. Hope it helps.

Phyll
Attachments
App9.zip
Dialog Example
(41.52 KiB) Downloaded 27 times
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Dialog

Postby Marbert » Mon Feb 13, 2012 1:18 pm

Thanks for your help, but the Spinner is working well. :)

I want to press a button, the dialog should appear, the user can enter a name and the file should be saved with this name.

On the Android-page I wasn't able to find this kind of dialog...

I've attached a screenshot, the dialog should look like this one (the text in the title means 'Save as'): :)
Attachments
P20120213131435 (640 x 400).jpg
P20120213131435 (640 x 400).jpg (52.74 KiB) Viewed 112 times
Marbert
Developer
Developer
 
Posts: 30
Joined: Sat Feb 04, 2012 7:31 pm

Re: Dialog

Postby Phyll » Mon Feb 13, 2012 10:35 pm

Hi Marbert,

The example dialog is just an Activity, like any other. If you want it to have an EditText just put an EditText in the xml, instantiate it in the Java code and use it just like you would in any other activity. Take the result string and send it back in the extras. You can add the buttons and an icon, just like your picture. What makes it a dialog is the style in the manifest, starting it for a result and returning the result. That's what I was trying to show you how to do.

Hope that helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: Dialog

Postby Marbert » Mon Feb 13, 2012 10:54 pm

Hi Phyll,

Oh, ok. :)

Thank your very much for your help!

Thanks
Marbert
Developer
Developer
 
Posts: 30
Joined: Sat Feb 04, 2012 7:31 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 23 guests