android - EditText items in a scrolling list lose their changes when scrolled off the screen -


I have a long scrolling list of editable text items created by a SimpleCursorAdapter and is ready with values ​​from the SQLite database.

I make it in this form:

  cursor = db.rawQuery ("SELECT _id, benchmark, localvate, globalware FRM" + dbTableName + "Criteria by order ", Blank); StartManagingCursor (cursor); MAdapter = New SimpleCursorAdapter (this, R. layout.video_edit_itmat_itm, cursor, new string [] {"criterion", "localweeter", "global weight"}, new entry [R.id.criterion_edit, R.id.localweight_edit , R.id.globalweight_edit}); This.setListAdapter (mAdapter);  

Scrolling list Many emulators are screen tall, the items display exactly - scrolling through them shows that everyone has the right value from the database.

I can make editing changes in any editing technique and accept new text and display it in the box. / P>

But ... if I scroll through the list enough to move edited items from the screen, when I scroll back to see it back, then its value is before I I make changes, its value has returned, i.e. My edits have been lost.

In an attempt to resolve it, I have done a getText to see in the editing text after my edit (and before a scroll) and receive the text found Original text , Even if the editing text is displaying my new text, it appears that the edit text has only accepted my edits on a large scale and that they are not obliged to edit text Receiving means is when you scroll on the screen to remove them.

Can anyone tell me what is happening here and whether editing edits need to be compelled to keep its edits?

Thanks

Ian

..I'll scroll so far from the list that the edited item from the screen is moved, when I scroll back to see it back, then its value has returned, before I made the change i.e. My edits have been lost.

Of course.

List rows get recycled. Your cursor can have 1000 records, but if you scroll through the list, then the 1,000 EditText widget can not be created. Instead, the rows are being recycled, depending on how many rows are visible at the same time, or 10, and the compelling process is the old EditText value to cursor Will scroll to the screen for the line, which must be before the database or the value of the edited value of the user).

And, since a regular cursor is unchanging, you do not have any way to make any kind of editing that will be transparent and put back in the list.

I suspect that it is possible that create EditTexts with ListView , possibly creating a custom adapter class and its Although you handle all the recycled rows, this is a fair work, and the underlying classes will only give you little support for this pattern.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -