2

I am creating an application in which i would like to know whether is it possible to show the list view inside a bottom sheet view .If so can anyone can tell me how i can do it because the examples which i have seen in bottom sheet shows only the share options. Can anyone tell me is there any example relating this bottom sheets

Ramesh R
  • 300
  • 4
  • 18
  • There should be no problem with this, except you should use a RecyclerView and not a ListView because RecyclerView supports nested scrolling, which is in part how Bottom Sheets work (assuming you are using CoordinatorLayout and the BottomSheetBehavior) – Karakuri Nov 11 '16 at 07:24

2 Answers2

2

Yes, You can implement Listview inside Bottom sheet View . first you need to create xml layout for Bottom sheet, and defined Listview.

bottom_sheet_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center|top"
    app:layout_behavior="@string/bottom_sheet_behavior"

    >
 <ListView
    android:id="@+id/bottom_sheet_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></ListView>
</LinearLayout>

Defined BottomSheetDialog in your Activity.

         BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(TagSetupActivity.this);
                View bottomSheetView = getLayoutInflater().inflate(R.layout.bootom_sheet_layout, null);
                bottomSheetDialog.setContentView(bottomSheetViewVideo);
                bottomSheetDialog.show();
     ListView sheetListView= (ListView) bottomSheetView.findViewById(R.id.bottom_sheet_listview);

    **and setadapter with data**
//**dataList == data fecth from sqlite.**

    adapter=new BottomSheetListAdapter(this,dataList);
    sheetListView.setAdapter(adapter);

Now, create BaseAdapter for showing data into List name with BottomSheetListAdapter

Nishchal Sharma
  • 1,070
  • 9
  • 16
-1

You can get an idea how to create a custom bottomsheet like a listview using below link

http://www.truiton.com/2016/07/android-bottom-sheet-example/