Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Custom Dialog 'header' to AlertDialog 'header'

I have made a custom Dialog, and I want the title to have a background like the AlertDialog.

Better said:

The place where it says "Custom Dialog"

alt text

Needs to have a 'header' like this:

alt text

I don't want to just add the image left to the text, but really implement the complete UI style shown.

Is this possible?

Here's the code I used for my custom dialog: Adding Image to Custom AlertDialog

like image 782
Galip Avatar asked Jan 19 '11 09:01

Galip


People also ask

What is the difference between dialog & DialogFragment?

Dialog: A dialog is a small window that prompts the user to make a decision or enter additional information. DialogFragment: A DialogFragment is a special fragment subclass that is designed for creating and hosting dialogs.

How do I import AlertDialog?

java file to add alert dialog code to launch the dialog. Modify layout XML file res/layout/activity_main. xml add any GUI component if required. Run the application and choose a running android device and install the application on it and verify the results.

Which method is used to set in AlertDialog?

Alert Dialog code has three methods:setTitle() method for displaying the Alert Dialog box Title. setMessage() method for displaying the message. setIcon() method is used to set the icon on the Alert dialog box.


1 Answers

Galip this is the code that worked for me

Dialog dialog = new Dialog(context);

dialog.setContentView(R.layout.dialoglayout);

dialog.setTitle("Pick A Colour");

and in my dialoglayout I had root element RadioGroup

Hope it helps.

like image 180
100rabh Avatar answered Sep 22 '22 18:09

100rabh