Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize the list items in an Android AlertDialog

I want to show multiple lines with different text styles for each item in a list using AlertDialog, but can't fine any example.

Does anyone know how to customize the items of an AlertDialog? Or do I really have to create an Activity with a ListView for this?

like image 864
infero Avatar asked Aug 29 '10 10:08

infero


People also ask

Which method is used to set the list in AlertDialog in Android?

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

How can I display a list view in an Android alert dialog?

Navigate to the app > res > layout and create a new layout file. Add a ListView as shown below. This layout would be displayed inside the AlertDialog.

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

Use setAdapter() on AlertDialog.Builder to supply your own custom ListAdapter for your list.

like image 187
CommonsWare Avatar answered Nov 15 '22 06:11

CommonsWare