Создание custom Bottom Navigation View

Задумка такая, у меня есть 4 кнопки и ViewPager, мне нужно чтобы при нажатие на кнопку открывал свой Fragment в ViewPager. Как это сделать?

xml файл

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <androidx.viewpager.widget.ViewPager
        android:id="@+id/ViewPager"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/bnm"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true" />

    <LinearLayout
        android:id="@+id/bnm"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentStart="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:orientation="vertical">

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/color_1" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/btn1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/color_4"
                android:text="@string/Btn_txt_1"
                android:textAllCaps="false"
                tools:ignore="ButtonStyle" />

            <Button
                android:id="@+id/btn2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/color_4"
                android:text="@string/Btn_txt_2"
                android:textAllCaps="false"
                tools:ignore="ButtonStyle" />

            <Button
                android:id="@+id/btn3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/color_4"
                android:text="@string/Btn_txt_3"
                android:textAllCaps="false"
                tools:ignore="ButtonStyle" />

            <Button
                android:id="@+id/btn4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:background="@color/color_4"
                android:text="@string/Btn_txt_4"
                android:textAllCaps="false"
                tools:ignore="ButtonStyle" />
        </LinearLayout>
    </LinearLayout>
</RelativeLayout>

Ответы (0 шт):