First of all, I’ll show you the result of this post to give you some motivation
As usual, you need to create the layout in main.xml file
Create layout for your List View Dialog my_list.xml
In the onCreate method, we need to:
- Load all the components and controls in the main.xml layout.
- Create an AlertDialog object which has all the controls in my_list.xml layout:
- Next, we create a List to store all items which will be shown in the List View Dialog
- Load the ListView object via my_list.xml file
- Create an adapter to hold all list items and set to the ListView
- Finally, handle OnItemClick of ListView:
Last but not least, implement onClick method to show List View Dialog:
Download Source Code ListView Dialog
Feel free to share!