tianzhuqiao / form

Form: form builder in Kotlin for Android
Apache License 2.0
15 stars 6 forks source link

Changing value but UI not updating. #3

Closed Robin-AF closed 2 years ago

Robin-AF commented 2 years ago

Hi,

Thanks for this wonderful library, as soon as I have more time I will contribute more to it. I'm curently trying to change data and see it reflect it's changes in the form.

For example

+FormItemLabel()
     .tag("Test")
    .title("Test")
    .subTitle("Test")
    .onItemClicked { item, viewHolder ->
       item.subTitle = "Test 2"
    }

Based on the above code, I would expect the subtext to change to "Test 2" when I press the item. Unfortunatly nothing happens, probably some kind of binding I need to activate?

(P.S I'm trying to do this in a custom FormITem but showing it in the FormItemLabel for testing purposes.)

Any help is welcome!

tianzhuqiao commented 2 years ago

How about calling adapter?.updateItem(item) after changing the item?

+FormItemLabel()
     .tag("Test")
    .title("Test")
    .subTitle("Test")
    .onItemClicked { item, viewHolder ->
       item.subTitle = "Test 2"
       adapter?.updateItem(item) 
    }
Robin-AF commented 2 years ago

Works perfectly thanks!