Search code examples
androidandroid-popupwindow

How to create a PopupWindow with images?


I'm trying to create a popup window similar to programmatically. Unfortunately I couldn't figure out any helpful resource so far for creating a similar popup.

PopupWindow from Android Design Guidelines


Solution

  • You can do it with Dialog

        final Dialog dialog = new Dialog(context);
        dialog.setContentView(R.layout.chat_custom_dialog);
        dialog.setTitle("custom dialog");
        dialog.show();
    

    where dialog.setContentView(R.layout.chat_custom_dialog); will set the layout of the dialog.

    And if you want to update the dialog's layout views you can call the dialog.findViewById(id) to get the view inside of the layout same as what you are doing in the activity