I have an EditText set for number input inside a ViewHolder. I want to save the value somewhere as soon as the user is done inputting it, so I wait for the "Done"-Button to be pressed. Unfortunately, the value I get when I use getText() on the EditText is the old one, which means at the time the method is called the internal state has not been updated yet.
I have found similar cases with EditTextPreference elements, however the solution there (which was using the preference object parameter the callback function instead) can't be applied here, since onEditorAction() does not have such a parameter.
holder.input = (EditText) convertView.findViewById(R.id.input_element_edittext);
holder.input.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
// is actually the old value
Log.w("new value", holder.input.getText().toString());
}
return false;
}
});
(I'm confused why I couldn't find any solutions for this, since it seems to be a basic problem)
I'd appreciate any ideas on how to get this to work.