title: How to use bottom sheet in fragment class instead of Activity Class?
body: <p>I am trying to use the bottom sheet in a click listener but I am getting an error on this line.</p>
  
  <p><strong>bottomSheetFragment.show(getSupportFragmentManager())</strong></p>
  
  <blockquote>
    <p>Cannot resolve method 'show(?, java.lang.String)' Cannot resolve
    method 'getSupportFragmentManager()</p>
  </blockquote>
  
  <p>I want to use the bottom sheet in a fragment class.</p>
  
  <p><strong>SubCategoryDetailFragment.java</strong></p>
  
  <pre><code>  public class SubCategoryDetailFragment extends Fragment {
  
          TextView txtv_sort;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              View view= inflater.inflate(R.layout.fragment_sub_category_detail, container, false);
              toolbar = ((MainActivity) getActivity()).findViewById(R.id.toolbar);
              toggle = ((MainActivity) getActivity()).getToggle();
              shimmerContainer = view.findViewById(R.id.shimmer_view_container);
              recyclerView_subcatDetail = view.findViewById(R.id.recycler_view_subCategoryDetail);
  
             txtv_sort = view.findViewById(R.id.txtv_sort);
  
              toggle.setDrawerIndicatorEnabled(false);
              toggle.setHomeAsUpIndicator(R.drawable.back);
              toggle.setToolbarNavigationClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      getActivity().onBackPressed();
                  }
              });
  
  
           txtv_sort.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
                      bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
                  }
              });
  
              return view;
          }
  
      }
  </code></pre>
  
  <p><strong>BottomSheetFragment.java</strong></p>
  
  <pre><code>public class BottomSheetFragment extends Fragment {
  
  
      public BottomSheetFragment() {
          // Required empty public constructor
      }
  
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          // Inflate the layout for this fragment
          return inflater.inflate(R.layout.fragment_bottom_sheet, container, false);
      }
  
  }
  </code></pre>
  
  <p><strong>fragment_bottom_sheet.xml</strong></p>
  
  <pre><code>&lt;LinearLayout 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"
      android:orientation="vertical"
      android:paddingBottom="8dp"
      android:paddingTop="8dp"
      tools:context=".Fragments.BottomSheetFragment"&gt;
  
      &lt;!-- NOTE: This list should be displayed in a list
      instead of nested layouts --&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:foreground="?attr/selectableItemBackground"
          android:orientation="horizontal"
          android:paddingBottom="8dp"
  
          android:paddingTop="8dp"&gt;
  
          &lt;ImageView
              android:layout_width="24dp"
              android:layout_height="24dp"
              android:layout_marginRight="32dp"
              android:src="@drawable/ic_launcher_background"
              android:tint="#737373" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:text="Preview"
              android:textColor="#737373"
              android:textSize="16sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:foreground="?attr/selectableItemBackground"
          android:orientation="horizontal"
          android:paddingBottom="8dp"
  
          android:paddingTop="8dp"&gt;
  
          &lt;ImageView
              android:layout_width="24dp"
              android:layout_height="24dp"
              android:layout_marginRight="32dp"
              android:src="@drawable/ic_launcher_background"
              android:tint="#737373" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:text="Share"
              android:textColor="#737373"
              android:textSize="16sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:foreground="?attr/selectableItemBackground"
          android:orientation="horizontal"
          android:paddingBottom="8dp"
  
          android:paddingTop="8dp"&gt;
  
          &lt;ImageView
              android:layout_width="24dp"
              android:layout_height="24dp"
              android:layout_marginRight="32dp"
              android:src="@drawable/ic_launcher_background"
              android:tint="#737373" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:text="Get link"
              android:textColor="#737373"
              android:textSize="16sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:foreground="?attr/selectableItemBackground"
          android:orientation="horizontal"
          android:paddingBottom="8dp"
  
          android:paddingTop="8dp"&gt;
  
          &lt;ImageView
              android:layout_width="24dp"
              android:layout_height="24dp"
              android:layout_marginRight="32dp"
              android:src="@drawable/ic_launcher_background"
              android:tint="#737373" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:text="Make a Copy"
              android:textColor="#737373"
              android:textSize="16sp" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:clickable="true"
          android:foreground="?attr/selectableItemBackground"
          android:orientation="horizontal"
          android:paddingBottom="8dp"
  
          android:paddingTop="8dp"&gt;
  
          &lt;ImageView
              android:layout_width="24dp"
              android:layout_height="24dp"
              android:layout_marginRight="32dp"
              android:src="@drawable/ic_launcher_background"
              android:tint="#737373" /&gt;
  
          &lt;TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_vertical"
              android:text="Email a Copy"
              android:textColor="#737373"
              android:textSize="16sp" /&gt;
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>