I am a long-time, self-taught, amateur VB programmer who is now trying to teach himself Java and Android simultaneously. I say this so you will know that I don't speak the lingo well, and am very very new to these two pursuits.
I have developed an Android form that has a series of EditText boxes, the contents of each which I wish to save to an array once the user has filled it in. I have figured out how to do this if the user presses the Enter key. However, people don't actually do that: they click on the box, type, and then click on the next element.
I VB, I could write code for the lostfocus event. But I can't find a similar method in Java.
Finally the question: is there a way to capture when an EditText has lost focus, so I can save the typed data at that 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 everlastingly appreciated.