8
Tab Template My website: Android Studio 101 My YouTube Channel: Android Studio YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

Android Studio Tab Layouts Tutorial (Updated for Latest Android SDK)

Embed Size (px)

Citation preview

Tab Template

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

.java files

MainActivity

HomeFragment

NewsFragment

FAQsFragment

Layout

activity_main.xml

fragment_home.xml

fragment_news.xml

fragment_faqs.xml

Structure of Android Studioapp with Tabs

MainSliderFragment fragment_main_slider.xml

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

MainActivity

public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

}

FragmentManager FragmentManager; FragmentTransaction FragmentTransaction;

// Lets inflate the very first fragment // Here , we are inflating the MainSliderFragment as the first Fragment FragmentManager = getSupportFragmentManager(); FragmentTransaction = FragmentManager.beginTransaction(); FragmentTransaction.replace(R.id.containerView,new MainSliderFragment()).commit();

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

activity_main.xml

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

MainActivity

public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

}

FragmentManager FragmentManager; FragmentTransaction FragmentTransaction;

// Lets inflate the very first fragment // Here , we are inflating the MainSliderFragment as the first Fragment FragmentManager = getSupportFragmentManager(); FragmentTransaction = FragmentManager.beginTransaction(); FragmentTransaction.replace(R.id.containerView,new MainSliderFragment()).commit();

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

MainSliderFragment

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

MainSliderFragment

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial

fragment_main_slider.xml

My website: Android Studio 101

My YouTube Channel: Android Studio

YouTube Video of this Slide: Android Studio Tab Layouts Tutorial