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:


 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android=""  
   android:orientation="vertical" android:layout_width="match_parent"  

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


 <?xml version="1.0" encoding="utf-8"?>  
 <LinearLayout xmlns:android=""  
   android:orientation="vertical" android:layout_width="match_parent"  
     android:layout_height="wrap_content" />  


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:
 public class CustomAdapter extends FragmentPagerAdapter {  
   List<Fragment> mFragmentCollection = new ArrayList<>();  
   List<String> mTitleCollection = new ArrayList<>();  
   public CustomAdapter(FragmentManager fm) {  
   public void addFragment(String title, Fragment fragment)  
   //Needed for  
   public CharSequence getPageTitle(int position) {  
     return mTitleCollection.get(position);  
   public Fragment getItem(int position) {  
     return mFragmentCollection.get(position);  
   public int getCount() {  
     return mFragmentCollection.size();  

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:

 public class CustomFragment extends Fragment {  
   private String mText = "";  
   public static CustomFragment createInstance(String txt)  
     CustomFragment fragment = new CustomFragment();  
     fragment.mText = txt;  
     return fragment;  
   public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
     View v = inflater.inflate(R.layout.fragment_sample,container,false);  
     ((TextView) v.findViewById(;  
     return v;  

Go ahead and create your dialog's class:
 public class TabbedDialog extends DialogFragment {  
   TabLayout tabLayout;  
   ViewPager viewPager;  
   public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {  
     View rootview = inflater.inflate(R.layout.dialog_sample,container,false);  
     tabLayout = (TabLayout) rootview.findViewById(;  
     viewPager = (ViewPager) rootview.findViewById(;  
     CustomAdapter adapter = new CustomAdapter(getChildFragmentManager());  
     return rootview;  

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

Full source can be found here:

You may have experienced many times when you move between countries; your google language is determined from the IP of where you're browsing from. Here is how you can enforce your language of choice without having to use translate feature of chrome.

If one the google site you're on, there's no language switch in site, modify the url to and add the quey hl=(2 letter language name) e.g hl=en. If there are queries already before it, then &hl=en, if it's first, ?hl=en.


You may have experienced this problem a couple of time, where your SD Card decides to go haywire on you and the only available option on your device is Erase Everything (Format). Here are some simple fixes that may help.

Internal SD Card Reader Available: 

Try with SD Lock off:

if your laptop has an internal SD Reader, there exist two quick fixes that usually works.
insert you SD-Card in an SD-Card Adapter, and see if Windows detects it, if Windows does. Follow the following steps.

The first step is to note the assigned drive letter; These can be seen from This PC / My Computer / Disk Management.

  • Go to start, click on run (alternatively Window key + R) enter cmd.
    • or type in Start, Command Prompt.
  • Type chkdsk /f  /r /x driverletter: 
    • i.e drive letter is the letter assigned to your drive. e.g if the letter e is assigned to your drive, then sample input may look like this:      chkdsk /f /r /x e:     
if your card is not detected or after detection, you cannot access it or get these error messages:
Cannot open volume for direct access 
The type of the file system is RAW.
CHKDSK is not available for RAW drives.
The type of the file system is FAT32.
Error in IOCTL call.
Then the below solution may help out.

Try with Write Lock on

Sometimes, trying your sdcard with write lock on does the magic, although you don't get to run a checkdisk on your sdcard, but you get the opportunity to backup your files before attempting the format option on your phone. (As at time of writing, I just had similar problem and this worked).