Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragments #144

Closed
SeaRoth opened this issue Mar 12, 2018 · 2 comments
Closed

Fragments #144

SeaRoth opened this issue Mar 12, 2018 · 2 comments
Labels

Comments

@SeaRoth
Copy link

SeaRoth commented Mar 12, 2018

I'm trying to get this to work with fragments - is that possible?

I'm using MVVM
and I declare my onCreateOptionsMenu inside a Fragment instead of an Activity.

I've tried a few tactics but I keep running into errors and I feel like there's something I'm not seeing

image

@AllanWang
Copy link
Owner

bindSearchView is actually an extension function extending either an Activity or ViewGroup. You have two options:

  1. Add it in your activity, where you can show and hide it as you wish after binding. This is what I do, as toolbars are typically linked to activities vs fragment.

  2. Add it to any general viewgroup. Just make sure you call it from that viewgroup. You may need to manually adjust the menu y offset if your viewgroup doesn't fill your parent.

@SeaRoth
Copy link
Author

SeaRoth commented Mar 12, 2018

Wow that's embarrassing (because it was so easy, lol) - thank you for helping me!!!!!!!!!!!! =)

@SeaRoth SeaRoth closed this as completed Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants