Seachview search fragment data

0

In the application has toolbar and 2 tabs through TabLayout with 1 fragment on each tab.

I want to put the library MaterialSearchView to implement SearchView that will be done by researching the items that are in recyclerview TAB phones.

But I put MaterialSearchView in activity_main.xml

<com.mancj.materialsearchbar.MaterialSearchBar
    style="@style/MaterialSearchBarLight"
    app:mt_speechMode="false"
    app:mt_hint="Pesquisar telefones"
    app:mt_maxSuggestionsCount="10"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/searchBar" />

When I try to use MaterialSearchBar through the null point exception fragment.

I have to put the MaterialSearchBar in the xml of the fragment or have some way of use in activity xml?

    
asked by anonymous 25.02.2018 / 18:40

1 answer

0

I was able to resolve by leaving the MaterialSearchBar in the xml of the actionbar and put the fragment in that way.

Before

materialSearchBar = (MaterialSearchBar) view.findViewById(R.id.searchBar);

I switched to

materialSearchBar = (MaterialSearchBar) getActivity().findViewById(R.id.searchBar);
    
25.02.2018 / 19:04