<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sheshank Srivastava on Medium]]></title>
        <description><![CDATA[Stories by Sheshank Srivastava on Medium]]></description>
        <link>https://medium.com/@sheshanksrivastava?source=rss-7c3aae005466------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*10xF6W518WOuLCwf.</url>
            <title>Stories by Sheshank Srivastava on Medium</title>
            <link>https://medium.com/@sheshanksrivastava?source=rss-7c3aae005466------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 18:22:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sheshanksrivastava/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Creating ModalBottomSheet in Android…]]></title>
            <link>https://medium.com/@sheshanksrivastava/creating-modalbottomsheet-in-android-6a51953b5c8f?source=rss-7c3aae005466------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a51953b5c8f</guid>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[bottomsheetdialog]]></category>
            <category><![CDATA[bottomsheet]]></category>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Sheshank Srivastava]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 13:48:41 GMT</pubDate>
            <atom:updated>2020-06-19T14:04:51.364Z</atom:updated>
            <content:encoded><![CDATA[<p>Learn how to create a ModalBottomSheet and pass data from recyclerview to bottom sheet</p><figure><img alt="Bottom sheet in activity" src="https://cdn-images-1.medium.com/max/883/1*t_LjpLXZVhwE1_-b4PUspA.jpeg" /></figure><p>BottomSheetDialogFragment is a thin layer on top of the regular support library Fragment that renders your fragment as a <strong>modal bottom sheet</strong>, fundamentally acting as a dialog.</p><p>Modal bottom sheets render a shadow on the content below them to indicate that they are modal, essentially a dialog. If the content outside of the dialog is tapped then the bottom sheet is dismissed. Modal bottom sheets can be dragged vertically and dismissed by completely sliding them down.</p><h3><strong>Step 1: Creating a new project</strong></h3><p>Open android studio then go to File -&gt; New Project. Then select Empty Activity and press Next. After that provide name to you project, fill out all the details and press Finish.</p><h3><strong>Step 2: Add design library to the Project</strong></h3><pre>implementation &#39;com.google.android.material:material:1.3.0-alpha01&#39;</pre><p>Add the design library to your build. gradle (Module.app) file. And press on ‘Sync Now’ on top right corner. Once build the gradle file is finished.</p><h3><strong>Step 3:</strong> Setup the Xml Files</h3><p>Start by adding Recycler View to your Activity_Main.xml. Don’t forget id’s to your views everytime you create any.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f6dfdf7217b88f887236c53dee4882df/href">https://medium.com/media/f6dfdf7217b88f887236c53dee4882df/href</a></iframe><p>Now the create User_ltem view which will hold the user name and the image of the user. Right click on the App -&gt; res -&gt;layout folder then go to New and Select Layout Resource file. I name this file user_item , you name it anything as per your project.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae056742dd06fa941080e6045de9b9e2/href">https://medium.com/media/ae056742dd06fa941080e6045de9b9e2/href</a></iframe><p>Let’s get done with all the xml Files at once</p><p>So the last xml file we require is our Bottom Sheet Dialog files. Do the same as you did for the User_Item view. Just change the name as something that can be easily defines as dialog in the file structure. For example, bottom_sheet_dialog.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd1558c9aa26b57f77a43a4f2a021632/href">https://medium.com/media/dd1558c9aa26b57f77a43a4f2a021632/href</a></iframe><p>Note:- Never use Capitalize letter in the naming of you xml file.</p><h3>Step 4: Start with creating Adapter for user list</h3><p>So in this file we are taking the list of user &amp; activity context and providing a function in which you can define functionality you need to get execute when the user item is clicked. So in the adapter we need to define an interface that will ask the activity what will happen if the item get clicked.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65083c5c89d7aac545ba9609735190ea/href">https://medium.com/media/65083c5c89d7aac545ba9609735190ea/href</a></iframe><h3>Step 5: Create Bottom sheet Class</h3><p>In order to make a class be bottom sheet one need to extend it with BottomSheetDialogFragment. After that you need to override one function inside the class called “onCreateView” . This function contains a Layout inflator and View group.</p><p>Inside this overridden function, we need to define the view component through which we want some action to happen.</p><p>And before that we need to get the name that is been clicked from the recycler view items. We will use getArgument().get() function to extract the name and in the get we pass the key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3013e74005130eff477b44b07f7a1ddf/href">https://medium.com/media/3013e74005130eff477b44b07f7a1ddf/href</a></iframe><h3>Step 6 : Setup the Main Activity</h3><p>In Main Activity, we need to define all the variable that are required to inflate the recyclerview.</p><p>While defining the adapter in the last we are setting the clickListener in which we will pass the name of the user to the bottom sheet and present the dialog to foreground.</p><p>In order to pass data to the dialog, first we will create an instance of ModalBottomSheet and After that we create an instance of Bundle class.</p><p>Following on we add data to the bundle instance using putString function where we pass the name of the clicked user for that we already have the position number coming from the adapter.</p><p>Then we set this bundle instance to the dialog using setArgument function.</p><p>After this we command the dialog to show up by using dialog.show(getSupportFragmentManager, “TAG”).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/166ae5259ff41e43c134d3156ca378bb/href">https://medium.com/media/166ae5259ff41e43c134d3156ca378bb/href</a></iframe><p>What are you waiting for christmas or Diwali</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*wVcKcfS5ZOPB_61x9G90mA.png" /></figure><h3>Run Your Code</h3><p>Hope you like this, Happy Coding.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a51953b5c8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>