0

I'm using the AutoCompleteTextView to allow users to search a from a list of countries. I want to have some default text preloaded in the search bar before the user clicks on it, such as "Search" or "Find Nearest Country". Is it possible to do this? If so how?

Right now, the app opens directly into the search box with the keyboard pulled up. Rather, I want the users to click on the bar before searching.

http://developer.android.com/reference/android/widget/AutoCompleteTextView.html

user1530318
  • 25,507
  • 15
  • 37
  • 48

1 Answers1

1

A TextView's hint seems to be exactly what you need. See android:hint for the XML attribute or setHint() for the corresponding Java method.

To prevent the keyboard from popping as soon as your activity is entered, you should set the android:windowSoftInputMode attribute in the activity declaration to stateHidden.

matiash
  • 54,791
  • 16
  • 125
  • 154
  • Awesome, the android:hint worked but it still opens up the application directly into the search bar with stateHidden and stateAlwaysHidden. Any idea why? – user1530318 May 20 '14 at 20:00
  • Strange, that solution always worked for us. Maybe try to set it directly on the window? See http://stackoverflow.com/a/9732810/82788 – matiash May 20 '14 at 20:10