0

I have created below function :

    private void openFilterStudentBottomSheetDialog(){
        View dialogView = getLayoutInflater().inflate(R.layout.bottomsheet_filter_students, null);
        BottomSheetDialog dialog = new BottomSheetDialog(this);
        dialog.setContentView(dialogView);

        tv_apply_student_filter=dialog.findViewById(R.id.tv_apply_student_filter);
        tabLayoutStudentList=dialog.findViewById(R.id.tabsStudentFilter);
        vpStudentList=dialog.findViewById(R.id.vpStudentFilter);

        StudentFilterPagerAdapter studentListPagerAdapter = new StudentFilterPagerAdapter(getSupportFragmentManager());
        vpStudentList.setAdapter(studentListPagerAdapter);
        vpStudentList.setOffscreenPageLimit(3);

        tabLayoutStudentList.setupWithViewPager(vpStudentList);

        tv_apply_student_filter.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StudentListActivity.this, "clicked", Toast.LENGTH_SHORT).show();
            }
        });

        dialog.show();
    }
}

I am trying to open BottomSheet Dialog which contains a button, tabs and viewpager inside it.

I can successfully take click for the button as you can see it in above method.

The issue is with ViewPager. Am getting below error :

java.lang.IllegalArgumentException: No view found for id 0x7f090252 (packagename:id/vpStudentFilter) for fragment Filter_MonthListFragment{c832d8b #0 id=0x7f090252 android:switcher:2131296850:0}

What might be the issue ?

You can check the layout as below :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:id="@+id/rl_container"
    android:layout_height="match_parent">
    <android.support.design.widget.TabLayout
        android:id="@+id/tabsStudentFilter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabMode="fixed" />
    <android.support.v4.view.ViewPager
        android:id="@+id/vpStudentFilter"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/tv_apply_student_filter"
        android:layout_below="@+id/tabsStudentFilter"/>
    <TextView
        android:id="@+id/tv_apply_student_filter"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_margin="@dimen/size_10"
        android:background="@drawable/drawable_square_6dp_for_filter"
        android:gravity="center"
        android:padding="@dimen/size_12"
        android:text="Apply Filter"
        android:textColor="@color/colorWhite"
        android:textSize="@dimen/font_size_16" />
</RelativeLayout>

Thanks.

Jaimin Modi
  • 1,530
  • 4
  • 20
  • 72

0 Answers0