Vincent Bernier
Vincent Bernier

Reputation: 8664

EditText need 2 touches to get focus

I now have waste a lot of time on this, and I feel the solution should be simple.

I have a ListView subclass that have rows that consist of an EditText and a TextView.
That Activity is the second one in my view hierarchy.
When I enter in it none of the EditText have focus and the keyboard don't shows up. (all good).
Now I touch an EditText, it gets focus, the keyboard shows up and at the same the EditText lose it's focus, at this point I touch the EditText again and now it get's and keep it's focus.

Any idea of what could get into conflict with each other to result in that behaviour?

Thanks,

Upvotes: 0

Views: 382

Answers (1)

Vincent Bernier
Vincent Bernier

Reputation: 8664

I've fixed this problem, but It so strange that I will post the solution in case some one have the same problem.

What is strange first. If I enter text in the EditText then commit my editing, the

public boolean onEditorAction(TextView v, int actionId, KeyEvent event)

is being call and at the end the my ListView get updated for FREE
If I add the following code into the Android manifest:

 <activity android:name=".ConverterActivity" 
        android:windowSoftInputMode="adjustPan"/>

I've got almost the correct behaviour, but now the only missing thing is that I don't get updates anymore.
since updates were working before I was assuming that the above code was not working.
But I've decide to tell myself, if that code work, what would be the problem?
Well it's not updating look for a way to update your ListView and "voilà".

((BaseAdapter) getListAdapter()).notifyDataSetChanged();

And now I'm wondering why was I getting update for Free in the first place... ???

So if you got a good explanation for this, I would gladly change the green check to you.

Upvotes: 1

Related Questions