Skip to content Skip to sidebar Skip to footer

Dynamic Length Of Listview Of Edittext Not Saving Input

I have listview of edittext boxes. I also have a button to add a new row into the list, thus, the list length is dynamic. However, when I entered text into the edittext and press

Solution 1:

Your idea is fine, but you need to persist the edittext's data. Try adding textwatcher to each edittext and save the text for each edittext in a array or something

Solution 2:

A ListView recycles its row views anyway, so this would still be a problem without changing the list length. Rows that scroll off the visible portion of the ListView would lose their contents. To fix the problem, text entered into the EditText needs to be stored in the underlying data model, not just in the view.

You'll probably need to add a TextWatcher (with addTextChangedListener()) to each EditText. When one of the TextWatcher callbacks is called, get the text from the EditText and save it into the data model.

To keep track of which data element to save to during the TextWatcher callback, you might use a technique similar to the one used with the RatingBar in this CommonsWare sample.

Post a Comment for "Dynamic Length Of Listview Of Edittext Not Saving Input"