How to Create a custom Dialog with Tabs (Android)

image from

Just earlier working on an app, I realized I needed to display tabbed information to users in a dialog box. This is quite different from the usual Tabbed Activity.


The first step is to make sure you have "'" in your build.gradle file.


Next is to create the layout xml files for the custom dialog and your fragment. Your custom dialog may look like this:


And for the purpose of this tutorial, we will use a minimal Fragment, like the one indicated below:



Next up is, building the java classes for the dialog, the fragment adapter, and the fragments.

Here is a sample implementation of the viewpager's adapter:
Note: you must override getTitle for the Tabs to have proper names.

Below is also a sample fragment for illustration purposes, we'll keep it simple for now:

Go ahead and create your dialog's class:

And there you have it, it displays similarly to what's shown below:

Full source can be found here:


  1. This comment has been removed by the author.

  2. This is what I have been looking for. Thank you. One question however. I am using a RecyclerView in my CustomFragments. How would I pass the data from the RecyclerView in CustomFragment to MainActivity?

    1. how create two tabbed dialog box one tab for login and another for signup,

  3. how to define getChildFragmentManager(), please explain.