Hi, Everyone. Anyone can help me here. how can i h...
# android
s
Hi, Everyone. Anyone can help me here. how can i how to add multiple selection in callback, Simply i have Lambda of ListDataResponse, on callback.invoke function i am trying to pass Array of all DataResponse in Lamda, and simply pass that onClick event to Submit view. Code Snippet. Passing this to My Parameter inside Adapter
val callback: ((List<DataResponse>) -> Unit)? = null,
Calling it inside onBindViewHolder
callback?.invoke(selectedOptions).
Current Behaviour. it's taking only simple DataResponse, I am trying to take all values whichever i select here not just single value
not kotlin but kotlin colored 1
f
Can you show the code how you create and add a value to selectedOptions? better to show more code
f
I saw that you are pass : val callback: ((OptionResponse) -> Unit)? = null. . it is not List<DataResponse> . However, I think single instance is good, because in Fragment (where you use Adapter) you can implement this callback and send the new selected option to the ViewModel. ViewModel will keep the list of selected options.
If you want to show the selected options on the list, you should do it in ViewModel by using the list of OptionResponse and list of selected options, then pass the new list to the Adapter.