Discussion:
EditText in Header of ListView loses focus after first character is entered
Justin Glaeser
2010-12-23 22:37:35 UTC
Permalink
Hello,

I have inflated a relativeLayout with a EditText inside and I am using
it as a filter for the list in the list header.

mListView.addHeaderView(searchBar, null, true);


Selecting the EditText causes the input to gain focus and the soft
keyboard to show itself; however, after entering in the first letter
the list is filtered, and the EditText focus is gone. Typing other
characters has no effect on the input and I must reselect the input in
order to type the next letter. Any suggestions on how the EditText
can keep the focus and received additional keys presses from the
keyboard? Thanks.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Sarwar Erfan
2010-12-28 04:25:12 UTC
Permalink
See if your your problem related/similar to this?
https://groups.google.com/forum/?pli=1#!topic/android-developers/ciMrAhW2P7M

Regards
Sarwar Erfan
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Justin Glaeser
2011-01-04 00:58:53 UTC
Permalink
Nope this did not solve the problem.

I have a work around where the parent view is passing any onkey events
to the editText in the header so characters are showing up however the
focus still disappears.
See if your your problem related/similar to this?https://groups.google.com/forum/?pli=1#!topic/android-developers/ciMr...
Regards
Sarwar Erfan
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Justin Glaeser
2011-01-05 23:30:43 UTC
Permalink
Here is a little more information about the focus behavior.

When more then one character is typed into the EditText the EditText
loses focus and the dividers of the ListView disappear. If I scroll
the list the dividers appear again.

Here is the stack trace showing the ListView requesting focus (among
other things)

EditText(View).onFocusChanged(boolean, int, Rect) line: 2666
EditText(TextView).onFocusChanged(boolean, int, Rect) line: 6402
EditText(View).unFocus() line: 2594
RelativeLayout(ViewGroup).unFocus() line: 536
ListView(ViewGroup).handleFocusGainInternal(int, Rect) line: 402
ListView(View).requestFocus(int, Rect) line: 3605
ListView(ViewGroup).requestFocus(int, Rect) line: 1028
ListView(View).requestFocus(int) line: 3556
ListView(View).requestFocus() line: 3534
ListView.layoutChildren() line: 1543
ListView(AbsListView).onLayout(boolean, int, int, int, int) line:
1147
ListView(View).layout(int, int, int, int) line: 7035


Why does the ListView need focus at all? I am trying to understand
the details of how ListViews handle focus. Thanks.
Post by Justin Glaeser
Nope this did not solve the problem.
I have a work around where the parent view is passing any onkey events
to the editText in the header so characters are showing up however the
focus still disappears.
See if your your problem related/similar to this?https://groups.google.com/forum/?pli=1#!topic/android-developers/ciMr...
Regards
Sarwar Erfan
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Loading...