step1:
implementation 'com.google.android.material:material:1.1.0'
step2: activity
package com.example.mepositry;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import com.google.android.material.tabs.TabLayout;
import java.util.ArrayList;
import java.util.List;
public class TabDataActivity extends FragmentActivity {
List<Fragment> fragmentList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab);
List<String> curnewslist = new ArrayList<>();
curnewslist.add("娱乐");
curnewslist.add("军事");
curnewslist.add("财经");
curnewslist.add("体育")