Фрагмент диалогового окна нижней таблицы Элемент Viewpager не отображается?
Вот класс DialogFragment:
public class BottomSheetFragment extends BottomSheetDialogFragment {
TabLayout tabLayout;
ViewPager viewPager;
FilterAdapterBottom viewPagerAdapter;
@Override
public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style);
View view = LayoutInflater.from(getContext()).inflate(R.layout.fragment_bottom_sheet, null);
dialog.setContentView(view);
viewPager = view.findViewById(R.id.viewPager);
viewPagerAdapter = new FilterAdapterBottom(getFragmentManager());
tabLayout = view.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
viewPager.setAdapter(viewPagerAdapter);
tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager) {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
super.onTabUnselected(tab);
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) view.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
((BottomSheetBehavior) behavior).setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
String state = "";
switch (newState) {
case BottomSheetBehavior.STATE_DRAGGING: {
state = "DRAGGING";
break;
}
case BottomSheetBehavior.STATE_SETTLING: {
state = "SETTLING";
break;
}
case BottomSheetBehavior.STATE_EXPANDED: {
state = "EXPANDED";
break;
}
case BottomSheetBehavior.STATE_COLLAPSED: {
state = "COLLAPSED";
break;
}
case BottomSheetBehavior.STATE_HIDDEN: {
dismiss();
state = "HIDDEN";
break;
}
}
Toast.makeText(getContext(), "Bottom Sheet State Changed to: " + state, Toast.LENGTH_SHORT).show();
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
}
}}
вот XML-класс
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_marginTop="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabIndicator="@color/button_red_back"
app:tabMode="fixed" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewPagerDialog"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
а это адаптер:
public class FilterAdapterBottom extends FragmentPagerAdapter {
public FilterAdapterBottom(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
Fragment fragment = null;
if (position == 0)
{
fragment = new DateFilter();
}
else if (position == 1)
{
fragment = new EventFilter_fragment();
}
return fragment;
}
@Override
public int getCount() {
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
String title = null;
if (position == 0)
{
title = "Date Filters";
}
else if (position == 1)
{
title = "Event Filters";
}
return title;
}}
и Внутренняя активность, я использую Like this. единственный макет вкладки отображает не содержимое окна просмотра.
пожалуйста, помогите мне, я бы одобрил каждый ответ здесь.