Capturing EditText Lost Focus?

I just got done doing something similar to this. I handled it by making a for-loop that just got the contents of each edittext by id and added it's text to an array. I did this in the onclick method since I did it all after the user clicked a button String ohhai; String duh = et.getText().toString(); int number = Integer.

ParseInt(duh); List myCollection=new ArrayList(); EditText stuff; int editt; String loggy; for(int z = 0; z 0) result. Append(arr0); for (int h=1; h Append(separator); result. Append(arrh); }.

I just got done doing something similar to this. I handled it by making a for-loop that just got the contents of each edittext by id and added it's text to an array. I did this in the onclick method since I did it all after the user clicked a button.

String ohhai; String duh = et.getText().toString(); int number = Integer. ParseInt(duh); List myCollection=new ArrayList(); EditText stuff; int editt; String loggy; for(int z = 0; z 0) result. Append(arr0); for (int h=1; h Length; h++) { result.

Append(separator); result. Append(arrh); }.

Give code, or don't give an answer. Read the FAQ before posting please. – Dhaivat Pandya Jun 1 at 5:06 Added code.

If you need more help let me know – GQGK Jun 1 at 5:28 Thanks a lot. The identation's a bit funny, I'll fix that. – Dhaivat Pandya Jun 1 at 17:43 Yeah, it came straight out of my program.

Notice the weird variable names. And my habits for looks are bad. But thank you for the fix!

– GQGK Jun 1 at 20:26.

Let's go by parts: "I could write code for the lostfocus event. But I can't find a similar method in Java. ": Take a look at the OnFocusChangeListener API "is there a way to capture when an EditText has lost focus": Yes, using the listener above and abstract void onFocusChange(View v, boolean hasFocus) "Please remember that I am so new to this": we've been all new here at some point :) If you are respectful, and give back to the community (either by answers, or simply voting up/down and accepting answers), there's nothing to worry.

And then some: I'm a self-learner as you, so I feel your pain right now, and I'd like to give you some advise now that you're starting with android: You added two tags: java and android. Coding in java for a desktop is quite different than coding for an android device, so please take that into consideration. Are you really going to code in java or just in android?

Besides some obvious differences in the API, the main difference is in the user interaction. Most java programs expect a full keyboard and a static screen, while android apps rely on touches, and that is a key difference. Touch is important because usually there is no lost focus without the focus gain on some other View.

A typical EditText will be filled with a finger on an IME and that View will maintain the focus until the same finger will touches another View (perhaps an EditText, perhaps a Button). There are usually no clicks outside the "window". On the other hand, in an android device you expect a single user, rather than an unknown amount of users in a desktop.

Thus, saving the data and retrieving it is handled quite differently (see, for instance, How do I save an Android application's state? ) You can choose to capture the gain/loss of focus to perform an action, or wait until a button is clicked, or even use other methods (such a TextWatcher to save the data on every character input). So, you have plenty of options to design your app.

The hard part is to design smartly. Good luck!

Right now I'm focusing on programming for Android, but I am also trying to learn Java sufficfiently to replace VB for my desktop apps. I am a safety professional by trade, so I want desktop programs for data manipulation and android apps for fieldwork. – Ed Preston Jun 1 at 7:20 The onfocuschangelistener appears to be what I want, but I now have a new glitch: It works fine when I click on another EditText, but I can't get the EditText to release focus when I click on a spinner.

I've set the spinners' focusable and focusableontouch properties to true, but when I click, the onfocuschange method is not called (I set a toast in it so I could check). – Ed Preston Jun 1 at 19:38.

Touch is important because usually there is no lost focus without the focus gain on some other View. A typical EditText will be filled with a finger on an IME and that View will maintain the focus until the same finger will touches another View (perhaps an EditText, perhaps a Button). There are usually no clicks outside the "window".

On the other hand, in an android device you expect a single user, rather than an unknown amount of users in a desktop. You can choose to capture the gain/loss of focus to perform an action, or wait until a button is clicked, or even use other methods (such a TextWatcher to save the data on every character input). So, you have plenty of options to design your app.

The hard part is to design smartly.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions