1

I am working on a spinner in which I am getting values of the spinner from the database.

I want to add hint to this spinner...and the problem arising is that I cannot able to add hint to this spinner.

What should I do?...

Ashutosh
  • 125
  • 1
  • 11

3 Answers3

0

You have to create a costum adapter for your spinner. There are some tutorials on the web:

Android: Spinner hint

Community
  • 1
  • 1
TheOnlyJakobob
  • 541
  • 3
  • 14
0

I think you are trying to make an initial text in spinner. You can do it in many ways

How to make an Android Spinner with initial text “Select One”

Otherwise you can use a button instead of spinner and create a dialog when button clicked

Community
  • 1
  • 1
Ameer
  • 2,709
  • 1
  • 28
  • 44
  • If I make initial text as "Select One"..by default it will take this value in database..I want the hint should be in such a manner that when i select spinner then only it works...what happening now is that if am not selecting spinner, its by default taking the first value which I don't want. – Ashutosh Jun 25 '14 at 06:17
  • so just use a button with dialog, and populate the database in dialog – Ameer Jun 25 '14 at 06:19
  • no it wont, i did this tutorial too and the text "Select One" ist just a text in the spinner. The items from database are populated in activities not in the adapter. – TheOnlyJakobob Jun 25 '14 at 06:24
  • public SpinnerHintAdapter(Context context, ArrayAdapter spinnerAdapter, String hintText, int nothingSelectedLayout).... hint and the populating items are different things – TheOnlyJakobob Jun 25 '14 at 06:25
  • make hint in background(In xml as android:text) or make it through programitically – Ameer Jun 25 '14 at 06:27
  • Even after giving hint, without selecting spinner, it is taking first value bydefault as checked in the logcat. – Ashutosh Jun 25 '14 at 07:29
0

I have developed a little component to get this. Just add a hint text in AutoCompleteTexview and build CompleteSpinner with it

https://github.com/FernandoGaliay/CompleteSpinner