title: i want to use card view to launch new activity in fragments .can anyone help me androidx
body: <pre><code>public class GalleryFragment extends Fragment implements View.OnClickListener {
  
      private GalleryViewModel galleryViewModel;
  
      CardView bro,inv,cert,ban,card;
      public View onCreateView(@NonNull LayoutInflater inflater,
                               ViewGroup container, Bundle savedInstanceState) {
           galleryViewModel=
                  ViewModelProviders.of( this ).get( GalleryViewModel.class );
          View root = inflater.inflate( R.layout.fragment_gallery, container, false );
          CardView bro,inv,ban,card;
           cert = (CardView)root.findViewById( R.id.c1 );
  
  
  public void onClick(View v) {
          Intent i;
          switch (v.getId())
          {
              case R.id.c1:
                  i=new Intent( v.getContext(), hi.class);
                  startActivity(i );
                  break;
              case R.id.c2:
                  i=new Intent( v.getContext(), hii.class);
                  startActivity(i );
                  break;
  </code></pre>
  <p>i have tried using cardview in fragments and i need to open new activity but when i am pressing in gallery fragment it is crashing</p>