I am a long-time, self-taught, amateur VB programmer who is now trying to teach himself Java and Android at the same time. I am saying this so that you know that I am not very good at talking about jargon, and very new to these two classes.
I developed an Android form that has a series of EditText blocks, the contents of each of which I want to save in an array after the user has filled it. I figured out how to do this if the user clicks the Enter key button. However, people do not actually do this: they click on the field, type and then click on the next element.
I VB, I could write code for the lostfocus event. But I can not find a similar method in Java.
Finally, the question is: is there a capture method when EditText has lost focus, so I can save typed data in this type without relying on the Enter key?
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)){
Editable wasted=edittext_asset.getText();
vehdata[vehNo][Integer.parseInt((String) edittext_asset.getTag())]=wasted.toString();
return true;
}
return false;
}
Please remember that I am so new to this that I am often still not sure where to put code snippets to make them work (new file? Oncreate method? Who knows). Any guidance you can give me will be gratefully and eternally appreciated.
source
share