Creating Tabs in Android Studio with Tabbed Activity

CyberNaga · 427K views · 2016 · 15:43

Open on YouTube

Software (other)Web developmenttutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as the tutorial they followed to set up tabbed fragments, and as a cleaner starting point than the default Android Studio template code.

Recommended by 2 people across 2 different months, 2017 to 2018.

What it is

A 2016 screen-recorded tutorial from CyberNaga on building swipe tabs in an Android app using Android Studio's Tabbed Activity template. It walks through modifying the generated template so each tab has its own fragment class and layout, and the description adds a snippet for setting tab icons.

What people said

Recommends Martin R. L. · 2017-02 · Stack Overflow · on “Webview not working in fragment”

Solved it by re-doing my tab fragments without unnecessary code from android studio. This time I did like in this tutorial [this video] .

Recommends Adrian Stoica · 2018-01 · Stack Overflow · on “Send data from activity to fragment in Android”

I would like to add for the beginners that the difference between the 2 most upvoted answers here is given by the different use of a fragment. If you use the fragment within the java class where you have the data you want to pass, you can apply the first answer to pass data: Bundle bundle = new Bundle(); bundle.putString("edttext", "From Activity"); Fragmentclass fragobj = new Fragmentclass(); fragobj.setArguments(bundle); If however you use for example the default code given by Android Studio for tabbed fragments, this code will not work. It will not work even if you replace the default PlaceholderFragment with your FragmentClasses, and even if you correct the FragmentPagerAdapter to the ne

Cites ggblbl · 2017-07 · Stack Overflow · on “Android Sound in Tabbed Activity”

I have an app with 6 tabs. I followed this tutorial: [this video] . The tab XML files contain a scrollview and some buttons. I need to make a few of those buttons to make a sound when pressed. I can't seem to use an onClickListener and neither can I just make a function that I can call from the XML file. Can anyone tell me what to put in here: package com.ggblbl.soundsintabs; import android.media.MediaPlayer; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class Tab4 extends Fragment { MediaPlayer mediaPlayer; @Override public View onCreateView(LayoutInflater inflater, ViewGroup c

Cites niel · 2017-09 · Stack Overflow · on “Change a button text on android tab swipe or select”

I have a button on a tabbed activity, now every the activity is swiped or another tab is selected, i want to change the button text based on the fragment's index. How do i do that? I just followed this tutorial on creating android tabs: [this video] It's basically the default tabbed activity, it just created one java and xml file per fragment. This is my main_activity.java import android.support.design.widget.TabLayout; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import an