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

Setting CustomSuggestionAdapter #152

Open
hawajka76 opened this issue Jun 21, 2021 · 1 comment
Open

Setting CustomSuggestionAdapter #152

hawajka76 opened this issue Jun 21, 2021 · 1 comment

Comments

@hawajka76
Copy link

Hello,
I am trying to define a customsuggestionadapter using the method MaterialSearchBar.setCustomSuggestionAdapter
searchBar.setCustomSuggestionAdapter(suggestionsAdapter)

I am trying to implement my own callbacklisteners for the custom suggestion adapter which implements com.mancj.materialsearchbar.adapter.SuggestionsAdapter

suggestionsAdapter = DefaultSuggestionsAdapter(LayoutInflater.from(context)) .setListener(object: SuggestionsAdapter.OnItemViewClickListener{ override fun OnItemClickListener(position: Int, v: View?) { TODO("Not yet implemented") } override fun OnItemDeleteListener(position: Int, v: View?) { TODO("Not yet implemented") } })

When I do this however I get an error saying Type mismatch: inferred type is Unit but SuggestionsAdapter<*, *>? was expected

I'm somewhat new to Android programming, so I suspect I'm missing something simple. What could be a good way to fix this?

@hawajka76
Copy link
Author

I managed to get it working using the following code. Still not quite sure why, if anyone could explain that would be very helpful.

suggestionsAdapter = DefaultSuggestionsAdapter(LayoutInflater.from(context)) if (suggestionsAdapter is DefaultSuggestionsAdapter) (suggestionsAdapter as DefaultSuggestionsAdapter).setListener(object : SuggestionsAdapter.OnItemViewClickListener{})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant