gpt4 book ai didi

android - tabLayout 中不存在 setupWithViewPager

转载 作者:行者123 更新时间:2023-11-29 15:02:46 34 4
gpt4 key购买 nike

public class ActivityManageCustomer extends AppCompatActivity {    
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_customer);
ViewPager viewpager = (ViewPager) findViewById(R.id.viewpager);
viewpager.setAdapter(new AdapterFragmentCustomer(getSupportFragmentManager()));
TableLayout tabLayout = (TableLayout) findViewById(R.id.tabLayout);
tabLayout.setupWithViewPager(viewpager);
}
}

tabLayout 中不存在 setupWithViewPager

minSdkVersion 14

targetSdkVersion 23

最佳答案

导入这个:

import android.support.design.widget.TabLayout;

并替换为:

TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
tabLayout.setupWithViewPager(viewpager);

你使用的是错误的TableLayout

关于android - tabLayout 中不存在 setupWithViewPager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41909714/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com