ViewPager没有显示在bottomSheetDialog上

时间:2016-05-09 11:38:09

标签: android android-design-library bottom-sheet

ViewPager未显示在BottomSheetDialog上。这是实施。

public void show(final BoxItem boxItem) {
        bottomSheet = (mContext).getLayoutInflater().inflate(R.layout.layout_change_size_and_frequency, null);
        bottomSheetDialog.setContentView(bottomSheet);
        bottomSheetDialog.show();
        hashMap = boxItem.getFrequencyItemConfigHashMap();
        initViews();
        setupViewPagerAndTabs();
    }

    private void setupViewPagerAndTabs() {
        Set<String> keySet = hashMap.keySet();
        ViewPagerAdapter adapter = new ViewPagerAdapter(((AppCompatActivity) mContext).getSupportFragmentManager());
        for (String key : keySet) {
            adapter.addFragment(SearchDetailItemsFragment.getInstance(hash.get(key)), key);
        }
        viewPager.setAdapter(adapter);
        tabLayout.setupWithViewPager(viewPager);

    }

    private void initViews() {
        tabLayout = (TabLayout) bottomSheet.findViewById(R.id.tabs);
        viewPager = (ViewPager) bottomSheet.findViewById(R.id.viewPager);
    }

1 个答案:

答案 0 :(得分:0)

Dialogs上不允许碎片。我通过使用BottomSheetDialogFragment解决了这个问题,它允许做各种事情来保持片段的生命周期。