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.
Dependency
The first step is to make sure you have "'com.android.support:design" in your build.gradle file.Layouts
Next is to create the layout xml files for the custom dialog and your fragment. Your custom dialog may look like this:dialog_sample.xml
And for the purpose of this tutorial, we will use a minimal Fragment, like the one indicated below:
fragment_sample.xml
Implementation
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:
CustomAdapter.java
Below is also a sample fragment for illustration purposes, we'll keep it simple for now:
CustomFragment.java
Go ahead and create your dialog's class:
TabbedDialog.java
And there you have it, it displays similarly to what's shown below:
Full source can be found here: https://github.com/kunmi/BlogTutorials/tree/master/TabbedDialog
Full source can be found here: https://github.com/kunmi/BlogTutorials/tree/master/TabbedDialog
Great
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis 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?
ReplyDeletehow create two tabbed dialog box one tab for login and another for signup,
Deletehow to define getChildFragmentManager(), please explain.
ReplyDeleteHow to define HEIGHT of FragmentDialog, as WrapContent?
ReplyDelete