My layout contains ListView
, SurfaceView
and EditText
. When I click on the EditText
, it receives focus and the on-screen keyboard pops up. When I click somewhere outside of the EditText
, it still has the focus (it shouldn't).
I guess I could set up OnTouchListener
's on the other views in layout and manually clear the EditText
's focus. But seems too hackish...
I also have the same situation in the other layout - list view with different types of items, some of which have EditText
's inside. They act just like I wrote above.
The task is to make EditText
lose focus when user touches something outside of it.
I've seen similar questions here, but haven't found any solution...
Just put these properties in the top most parent.
You've probably found the answer to this problem already but I've been looking on how to solve this and still can't really find exactly what I was looking for so I figured I'd post it here.
What I did was the following (this is very generalized, purpose is to give you an idea of how to proceed, copying and pasting all the code will not work O:D ):
First have the EditText and any other views you want in your program wrapped by a single view. In my case I used a LinearLayout to wrap everything.
Then in your code you have to set a Touch Listener to your main LinearLayout.
I hope this helps some people. Or at least helps them start solving their problem.