运维开发网

Java TabLayout(Android支持设计)中的选项卡不会夸大内容

运维开发网 https://www.qedev.com 2020-03-12 18:41 出处:网络 作者:运维开发网整理
我有一个tablayout,来自 android设计支持库: 编译’com.android.support:design:23.0.1′ 有了这个,我想填充我的标签.但我没有那样做.我可以创建标签,但是它们无法夸大各自的内容: 它应该有来自LinearListView的条目,一个类似于从该框架导入的ListView的对象: 编译’com.github.frankiesardo:linearlist
我有一个tablayout,来自 android设计支持库:

编译’com.android.support:design:23.0.1′

有了这个,我想填充我的标签.但我没有那样做.我可以创建标签,但是它们无法夸大各自的内容:

Java TabLayout(Android支持设计)中的选项卡不会夸大内容

它应该有来自LinearListView的条目,一个类似于从该框架导入的ListView的对象:

编译’com.github.frankiesardo:linearlistview:1.0.1@aar’

我尝试了很多例子,但是我没有填充每个标签.有什么建议?

码:

JAVA:

从主要片段:

OverviewTabLayoutPagerAdapter adapter = new OverviewTabLayoutPagerAdapter(getActivity().getSupportFragmentManager(), productDataContent, getContext());
        ViewPager viewPager = (ViewPager) view.findViewById(R.id.viewpager);
        viewPager.setAdapter(adapter);
        TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tablayout);
        tabLayout.setupWithViewPager(viewPager);

OverviewTabLayoutPagerAdapter:

public class OverviewTabLayoutPagerAdapter extends FragmentPagerAdapter {

    final int PAGE_COUNT = 3;

    private String tabTitles[] = new String[] { "REVIEWS", "VIDEOS", "DEALS" };
    private SearchContent productDataContent;
    private Context context;

    public OverviewTabLayoutPagerAdapter(FragmentManager fm, SearchContent productDataContent, Context context) {
        super(fm);
        this.productDataContent = productDataContent;
        this.context = context;
    }

    @Override
    public int getCount() {
        return PAGE_COUNT;
    }

    @Override
    public Fragment getItem(int position) {
        Log.i("TAB_POSITION", String.valueOf(position));

        if (position == 0) {
            return OverviewTab1Fragment.newInstance(position, productDataContent);
        } else if (position == 1) {
            return OverviewTab2Fragment.newInstance(position, productDataContent);
        } else if (position == 2) {
            return OverviewTab3Fragment.newInstance(position, productDataContent);
        }

        return OverviewTab1Fragment.newInstance(position, productDataContent);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        // Generate title based on item position
        return tabTitles[position];
    }

OverviewTab * Fragment

0

精彩评论

暂无评论...
验证码 换一张
取 消