-
Notifications
You must be signed in to change notification settings - Fork 154
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
How to implement MaterialSearchView in a fragment? #96
Comments
You should handle the Search View on the Activity. If your Fragment needs the results you have a few options on how to send it to the fragment, such as:
|
I agree with Mauker on the solutions above, but I do think adding support for Fragment use would be beneficial. Can you explain more why you were unsuccessful in implementing it in your Fragment? What was the issue with the code above? |
java.lang.NullPointerException: Attempt to invoke virtual method 'void br.com.mauker.materialsearchview.MaterialSearchView.setOnQueryTextListener(br.com.mauker.materialsearchview.MaterialSearchView$OnQueryTextListener)' on a null object reference Facing this error while adding in fragment |
Is the search view on your fragment layout? Also, are you sure you're getting its reference once the view is inflated? I couldn't find where are you getting it on the code snippet you provided. |
Its a menu item and yes i m taking it reference as u can see in the above mentioned code snippet |
Try to find the MSV on your Inside the |
I have used it as a menu item on top of action bar i don't want to use it inside my fragment because i have 3 fragments where i want search so i want it to be a common part of the app |
Good evening, I'm try to implement this project in a fragment, but without sucess. Code:
Someone can help me please?
The text was updated successfully, but these errors were encountered: