package com.example.tabfragment;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.google.android.material.tabs.TabLayout;

public class MainActivity extends AppCompatActivity {
        Toolbar toolbar;
        ViewPager pager;
        TabLayout tabs;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        toolbar= findViewById(R.id.toolbar);
        pager= findViewById(R.id.pager);
        tabs=findViewById(R.id.tabs);

        setSupportActionBar(toolbar);
        getSupportActionBar().setTitle("Multiple Feature");

        ViewPagerAdapter adapter=new ViewPagerAdapter(getSupportFragmentManager());

        adapter.addfragment(new FragmentOne(),"Calculator");
        adapter.addfragment(new Fragmenttwo(),"Soundcloud");
        adapter.addfragment(new Fragmentthree(),"YouTube");
        adapter.addfragment(new BlankFragment(),"blank");

        pager.setAdapter(adapter);
        tabs.setupWithViewPager(pager);
    }
}
