Alert Dialog Box With Dynamic Content

In this post we are talking about creating dynamic content in alert dialog box.This is not the correct way but it is a way. It’s mostly for beginners in android developing. where we want to use dynamic content for alertdialog box.Like a sub catogery in categorys.managing and utilising space of mobile screen more effectively. First of all let me give you a hind what we are up to.

 

alert dialog box 1alert dialog box 2alert dialog box 3

 

 

 

 

 

 

 

 

 

First we need to create the Alertdialog box.Contents for Alert dialog box can be added in many ways. The first way is by code,it means write what we want directly in code like

. For advanced programmers it’s works but it’s bit difficult to do for biginers. The second method is creating a custom xml file for the Alertdialog box. It’s easy to make and understand. We go with the second way.



First step

The first step is to initialise some contents globally,so it can be accessed everywhere from the class.

Creating the custom Alert dialog box

Android uses xml file for creating Ui.Our custom ui is created using an xml file.Create an xml file for the ui in the layout folder of android studio.Below is a sample code.
I am using

dialog.xml




Now for the main part

MainActivity.java contain all the codeing part of the Alert dialog box

Leave a Reply

%d bloggers like this: