Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the message(body) of AlertDialog in onPrepareDialog()?

Tags:

android

Will you please anyone let me know how to change the Message (Body) of an alert dialog in onPrepareDialog().

I am not able to find any function like setText() even after typecasting the Dialog parament in the onPrepareDialog() function.

I dont want to use
removeDialog()
showDialog()
as it will be overhead to GC to clean the objects and if i go for custom dialog then code becomes huge for handling in case of themes.

Please let me know if anyone have idea of changing the text of an AlertDialog in the onPrepareDialog() function.

Thanks & Regards,
SSuman185

like image 283
Suman Avatar asked Feb 15 '11 07:02

Suman


People also ask

How can I customize AlertDialog in Android?

Step 1: Create a XML file: custom_layout. Add the below code in custom_layout. xml. This code defines the alertdialog box dimensions and add a edittext in it.

What is AlertDialog message?

Alert Dialog shows the Alert message and gives the answer in the form of yes or no. Alert Dialog displays the message to warn you and then according to your response the next step is processed. Android Alert Dialog is built with the use of three fields: Title, Message area, Action Button.

Which method is used to set in AlertDialog?

The way to make a checkbox list is to use setMultiChoiceItems . // setup the alert builder AlertDialog. Builder builder = new AlertDialog. Builder(context); builder.


1 Answers

Within onPrepareDialog just use:

((AlertDialog) dialog).setMessage("my text goes here");
like image 128
dave.c Avatar answered Oct 20 '22 11:10

dave.c