Code Monkey home page Code Monkey logo

Comments (10)

TheJuki avatar TheJuki commented on May 29, 2024

When you are logging the elements can you also check if itemView is null or not? Are you looping through the elements after the form has been rendered and displayed or before? My only guess is that itemView is null and cannot set visibility = View.GONE for that element. Which kind of form element is it?

from kformmaster.

dhaksddj avatar dhaksddj commented on May 29, 2024

Its a FormMultiLioneEditTextElement.

I am looping through after being displayed.

ItemView is NOT null and I can loop through the code that sets visibility to GONE (BaseFormElement line 239).

from kformmaster.

TheJuki avatar TheJuki commented on May 29, 2024

I think it might be the cache size then. Are you using addFormElements() to add form elements? If not, you should call setItems() after you modify the elements list. This will make sure the cache size is correct and notifyDataSetChanged is called.

from kformmaster.

dhaksddj avatar dhaksddj commented on May 29, 2024

So I call FormBuilder with just the activity (it used to have automeasure but thats gone) like this:

formBuilder = FormBuildHelper(activity!!)
formBuilder.attachRecyclerView(activity!!, recyclerView)

then I loop through my questions, creating elements as I go and then add them:

formBuilder.addFormElements(elements)

Apart from the first question, I make all of them visible = false. Then, as they answer questions I can check the answer and decide which elements to make visible.

The issue is changes to previously answered questions need questions after it to be made invisible again (because answering questions differently might mean making other questions visible).

So, based on your comment I tried this:

when (formElement) {
                is FormPickerDropDownElement -> formElement.setVisible(false)
                is FormMultiLineEditTextElement -> {
                    formElement.setVisible(false)
                }
            }
            formBuilder.setItems()

that made no difference. Any ideas?

from kformmaster.

TheJuki avatar TheJuki commented on May 29, 2024

Could it be that the field has focus? https://stackoverflow.com/a/28467157/4056401

Call currentFocus?.clearFocus() before your loop to hide the elements.

from kformmaster.

dhaksddj avatar dhaksddj commented on May 29, 2024

On what class?

from kformmaster.

dhaksddj avatar dhaksddj commented on May 29, 2024
when (formElement) {
                is FormPickerDropDownElement -> {
                    formElement.editView?.clearFocus()
                    formElement.setVisible(false)}
                is FormMultiLineEditTextElement -> {
                    formElement.editView?.clearFocus()
                    formElement.setVisible(false)
                }
            }

didn't work (also tried itemView which returns a view)

from kformmaster.

TheJuki avatar TheJuki commented on May 29, 2024

Hmm. I really don't know. Seems like an Android problem. Caching the RecylerView should have resolved most of the weirdness for each dynamic view in the list.

from kformmaster.

dhaksddj avatar dhaksddj commented on May 29, 2024

Caching is the default anyway?

from kformmaster.

TheJuki avatar TheJuki commented on May 29, 2024

Yes. But apparently it does not solve all of the issues with using a RecylerView for a form.

from kformmaster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.