title: How to pass the data from the fragment to bottom sheet in android?
body: <p>I want to get data from the fragment listview and view it in a bottom sheet layout. I want to view like above attached image. Please help me.<a href="https://i.stack.imgur.com/nZUNr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nZUNr.png" alt="enter image description here"></a> </p>
  
  <p>I done code for viewing the bottom sheet ,when user clicks the listview items the bottom sheet will be opened.In the bottom sheet the listview item details in the fragment should be viewed in a bottom sheet.The code for my project is attached below.</p>
  
  <pre><code> @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.fragment_call_log, container, false);
      callLogList = (ListView) v.findViewById(R.id.callLogList);
      contactPhoto = (ImageView) v.findViewById(R.id.missedImage);
  
      final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(getActivity());
      View bottomSheetView = inflater.inflate(R.layout.bottom_sheet,null);
      bottomSheetDialog.setContentView(bottomSheetView);
  
  
     String[] textString = new String[]{"Play", "Share", "Call", "add Notes","Add To Block","Delete"};
    int[]  drawableIds = new int[]{R.drawable.play_icon, R.drawable.share_icon, R.drawable.call_icon, R.drawable.add_notes_icon,
              R.drawable.block_icon,R.drawable.delete_icon};
  
      final ListView listbottom = (ListView)bottomSheetDialog.findViewById(R.id.listBottomSheets);
      CustomAdapter adapter = new CustomAdapter(this,  textString, drawableIds);
      listbottom.setAdapter(adapter);
  
  
  
  
      listbottom.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int position, long id) {
  
  
  
              switch (position)
              {
                  case 0:
                      Toast.makeText(getActivity(),"playing the song",Toast.LENGTH_SHORT).show();
                      break;
                  case 1:
                      Toast.makeText(getActivity(),"sharing the song",Toast.LENGTH_SHORT).show();
                      break;
                  case 2:
                      Toast.makeText(getActivity(),"deleting the song",Toast.LENGTH_SHORT).show();
                      break;
                  case 3:
                      Toast.makeText(getActivity(),"blocking the song",Toast.LENGTH_SHORT).show();
                      break;
                  default:
                      Toast.makeText(getActivity(),"nothing selected ",Toast.LENGTH_SHORT).show();
                      break;
  
              }
  
          }
      });
  
  
      BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from((View) bottomSheetView.getParent());
      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
      bottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
      bottomSheetBehavior.setPeekHeight(320);
  
      bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
          @Override
          public void onStateChanged(@NonNull View bottomSheet, int newState) {
              Toast.makeText(getActivity(),"Hidden",Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void onSlide(@NonNull View bottomSheet, float slideOffset) {
  
          }
      });
  
      callLogList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
              bottomSheetDialog.show();
          }
      });
  
      setRetainInstance(true);
  
      return v;
  }
  </code></pre>