Skip to content

Instantly share code, notes, and snippets.

@john-lorrenz
Created March 30, 2020 22:13
Show Gist options
  • Save john-lorrenz/4f63dc1225b4b07e55f69df464457829 to your computer and use it in GitHub Desktop.
Save john-lorrenz/4f63dc1225b4b07e55f69df464457829 to your computer and use it in GitHub Desktop.
Bottom sheet dialog
private fun openBottomSheetDialog() {
val view = layoutInflater.inflate(R.layout.bottom_sheet_dialog, null)
val dialog = BottomSheetDialog(context)
dialog.setContentView(view)
dialog.show()
dialog.findViewById<LinearLayout>(R.id.button_1)!!.setOnClickListener {
println("button 1 is clicked")
}
dialog.findViewById<LinearLayout>(R.id.button_1)!!.setOnClickListener {
println("button 2 is clicked")
dialog.dismiss()
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button 1"
android:id="@+id/button_1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button 2"
android:id="@+id/button_2"/>
</LinearLayout>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment