commit451 / modalbottomsheetdialogfragment Goto Github PK
View Code? Open in Web Editor NEWModal bottom sheet dialog based on the Material Guidelines
Home Page: https://material.io/components/sheets-bottom
License: Apache License 2.0
Modal bottom sheet dialog based on the Material Guidelines
Home Page: https://material.io/components/sheets-bottom
License: Apache License 2.0
Thanks again for helping me on the last issue. This is how I'm setting up the modal:
implementation 'com.github.Commit451:ModalBottomSheetDialogFragment:1.0.0'
my_modal_menu,xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_view"
android:icon="@drawable/ic_view"
android:title="View" />
<item
android:id="@+id/action_delete"
android:icon="@drawable/ic_delete"
android:title="Delete" />
</menu>
Then, I add a header to my modal and add the menu:
ModalBottomSheetDialogFragment.Builder()
.add(R.menu.my_modal_menu)
.header("Pick an option")
.show(childFragmentManager, "my_modal")
The bottom modal shows up, but is throwing an throwIndexOutOfBoundsException
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.get(ArrayList.java:308)
at com.commit451.modalbottomsheetdialogfragment.ModalBottomSheetDialogFragment$Adapter$onCreateViewHolder$1.onClick(ModalBottomSheetDialogFragment.kt:212)
So I went and debugged and we got this:
When I'm pressing the second option on the bottom sheet modal, you get the adapterPosition
which you can see below is 2.
But the problem is I only have two options, position 0 and 1:
Then the error is thrown. Maybe it has something to do to the fact I'm using a header so the adapterPosition
is 2 because the header is 0?
Thanks!
Hi, I want the selected index or position in Option Object. How can I get this?
Kind Regards,
Hassan
I'm trying to show a bottom sheet inside a custom fragment. In this fragment I implement the Listener:
class MyFragment : Fragment(), ModalBottomSheetDialogFragment.Listener {
}
Then the method:
override fun onModalOptionSelected(tag: String?, option: Option) {
Snackbar.make(root, "Selected option ${option.title} from fragment with tag $tag", Snackbar.LENGTH_SHORT)
.show()
}
Then, when I want to show the bottom sheet dialog, I just call this:
ModalBottomSheetDialogFragment.Builder()
.add(R.menu.menu_options)
.show(activity!!.supportFragmentManager, "my_bottom_sheet")
But just after the execution I get this error:
java.lang.IllegalStateException: ModalBottomSheetDialogFragment must be attached to a parent (activity or fragment) that implements the ModalBottomSheetDialogFragment.Listener
at com.commit451.modalbottomsheetdialogfragment.ModalBottomSheetDialogFragment.bindHost(ModalBottomSheetDialogFragment.kt:136)
at com.commit451.modalbottomsheetdialogfragment.ModalBottomSheetDialogFragment.onViewCreated(ModalBottomSheetDialogFragment.kt:115)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1439)
It is possible to show the bottom sheet dialog inside a fragment?
how we can change background of base Dialog ???
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.