Note that there are some explanatory texts on larger screens.

plurals
  1. POEditText loses content on scroll in ListView
    primarykey
    data
    text
    <p>I have list item with EditText in it, I dont know how many items there will be. I have a problem when I enter some text in EditText, and then scroll down a ListView, after I've scroll up again there is no text in my first EditText, or there is some text from other EditText from ListView.</p> <p>I've tried TextWatcher, and saving data to array, but problems is that returned position of view in ListView isnt always right, so I lost some data from array. -.-</p> <p>How to detect correct position of view in ListView?</p> <p>For example:</p> <p>If I have 10 items in ListView, and only 5 of them are currently visible. Adapter return position from 0 to 4...thats ok. When I scroll down position of item 6 is 0...wtf? and i lose data from array on position 0 :)</p> <p>Im using ArrayAdapter.</p> <p>Please help.</p> <p>Here's some code:</p> <pre><code>public View getView(int position, View convertView, ViewGroup parent) { tmp_position = position; if (convertView == null) { holder = new ViewHolder(); LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.element_in_game, null); holder.scoreToUpdate = (EditText) convertView .findViewById(R.id.elementUpdateScore); holder.scoreToUpdate.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { scoresToUpdate[tmp_position] = s.toString(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); initScoresToUpdateEditTexts(holder.scoreToUpdate, hint); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); holder.scoreToUpdate.setText(scoresToUpdate[tmp_position]); } return convertView; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload