A. Sachdeva
02/27/2021, 8:29 PMSnapshotStateList
directly for learning purposes instead of using mutableStatelistof.
But:
1. the on click log and delete action seems to work, but when done too quickly, started giving index out of bounds. is it because of my implementation?
2. my main goal was to show a toast on item click, but could not access LocalContext.current
, so had to test with logs. how to get context?
3. onEdit was not working immediately, but would show effect after scrolling. if it was recycler view, i would say a classic problem of adapter not reflecting latest changes due to lack of notifydatasetchanged call. so again, what did i missed?jaqxues
02/27/2021, 9:21 PMlist.remove(element)
should do
val ctx = LocalContext.current
val onClick = { ... Toast.makeText(ctx,...) }
The edit modifies the element itself, which cannot be picked up by the statelist. Your objects have to be immutable, you have to delete add or replace entire elements in the list to work correctly
This code in general is somehwat.... Questionable. You should really look at compose/kotlin samples to get a feeling of how this should work and be usedA. Sachdeva
02/27/2021, 9:39 PMjaqxues
02/27/2021, 9:48 PMA. Sachdeva
02/28/2021, 6:16 AM