Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 885
James andresakis Avatar asked Oct 05 '22 18:10

James andresakis


1 Answers

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.

like image 184
Pozzo Apps Avatar answered Oct 10 '22 03:10

Pozzo Apps