James andresakis
James andresakis

Reputation: 5415

Android - how to keep an AutoCompleteTextView from keeping focus

I have a pretty complex layout that has multiple types of views and I have one AutoCompleteTextView that keeps focus. I have relativeLayouts which I keep set to GONE and then when I expand them the screen shoots back up to the autoCompleteTextView which is annoying when you are way down the view. How can I keep the AutocompleteTextView from keeping focus without setting it to not being able to take focus because when you do this you cant click on it to write in it. I tried setting it to not take focus and adding an onclick listener where I basically said if not in focus take focus but that didnt work. I would like to be able to have it so I can start the activity with the AutoCompleteTextView having no focus and then when someone clicks on it they can write in it and when they are done it loses focus. Any help on the matter would be much appreciated.

Upvotes: 5

Views: 5619

Answers (1)

Pozzo Apps
Pozzo Apps

Reputation: 1857

Place this on its parents layout (like linearLayout):

android:focusable="true" android:focusableInTouchMode="true"

This way LinearLayout will take focus when user join your activity and the keyboard will not show.

Upvotes: 4

Related Questions