How to Inflate Alert Dialog Box with Another Layout

Lets Start by  making a simple  alert dialog box .

In main.xml I am defining a button on click of which we will launch alert dialog box .

now in our main activity we will bind button id and declare alertdialog box.

now  on click listener we will call a alert dialog box

we will have something like this

simple alert dialog box

 

 

 

 

 

 

 

 

 

 

 

We will now define a new xml in res/layout, ne.xml

Now we will inflate the existing layout with our new layout in our main activity

we will replace alertbox.show (); in main activity

by      builder.show(); and we will get

inalted alert dialog box

 

 

 

 

 

 

 

Stay Tuned for more Android Tips

The following two tabs change content below.
sunny
Co-Founder of www.deadmango.com . Loves to read and write about emerging technologies, a small time open source enthusiast and a big time android lover.