2016-11-11 49 views
1

我正在創建一個應用程序,我想知道是否可以在底部工作表視圖中顯示列表視圖。如果任何人都可以告訴我怎麼做才能做到這一點,因爲我在底部工作表中看到的例子只顯示了選項。 誰能告訴我,有沒有關於這個底部的紙張如何在android中使用列表視圖在sqlite中創建顯示數據的底部視圖

任何例子
+0

應該有這個沒有問題,只是因爲RecyclerView支持嵌套的滾動,這是你應該使用RecyclerView,而不是一個ListView部分Bottom Sheets如何工作(假設您使用CoordinatorLayout和BottomSheetBehavior) – Karakuri

回答

1

是的,你可以在裏面實現列表視圖,以創建像一個列表視圖定製bottomsheet底部工作表視圖。 首先,您需要爲底部工作表創建xml佈局,並定義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> 

在活動定義BottomSheetDialog。

  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); 

現在,創建BaseAdapter顯示具有BottomSheetListAdapter數據到列表名稱

+0

感謝您的Java代碼實現 –

+0

歡迎@MuhammadSufiyan – NishchalAndroid

相關問題