Questions tagged [spinner]

Spinner is a widget that allows the user to select an item from a group, like a dropdown list.

A Spinner is a widget that allows the user to select an item from a group. It is similar to a dropdown list and will allow scrolling when the list exceeds the available vertical space on the screen.

Initial help

Code sample

Android design guide

5148 questions
53
votes
9 answers

How do you get the selected value of a Spinner?

I am trying to get the selected items string out of a Spinner. So far I have gotten this: bundle.putString(ListDbAdapter.DB_PRI, v.getText().toString()); This does not work and gives a class casting exception (I thought I could cast a View to a…
Matthew Hall
  • 533
  • 1
  • 4
  • 4
51
votes
10 answers

Creating a setError() for the Spinner

How do you create the setError() (similar to that of a TextView/EditText) function for a Spinner? The following doesn't work: I tried extending the Spinner class and in the constructor: ArrayAdapter aa = new…
Sameer Segal
  • 21,813
  • 7
  • 42
  • 56
51
votes
7 answers

How can I use onItemSelected in Android?

package org.example.mbtiapplication; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import…
50
votes
1 answer

ViewPostIme pointer 1/0

I have the following code with no compilation errors, just resulting in an infinite loop... I don't get where the problem is. When I click the Button, I want to create an object using the values entered in the edittexts and pass them to another…
Anais
  • 627
  • 1
  • 8
  • 13
50
votes
4 answers

Android spinner with underline appcompat

I am using a appcompat theme for my application. Need to know how i can show underline to spinner. It is just showing anchor. I tried setting up underline using android:background but it makes the anchor disappear.
Pritam Kadam
  • 3,203
  • 4
  • 19
  • 41
49
votes
3 answers

Set Key and Value in spinner

I have a spiner and I want set a key and a value on this,I use of HashMap,It's work,but show one row,like this: Code: final View rootView = inflater.inflate(R.layout.fragment_photos, container, false); Spinner…
Nima.S-H
  • 777
  • 1
  • 9
  • 19
49
votes
3 answers

Android - configure Spinner to use array

I declare my Spinner in the following manner (it's very static so I have 2 string arrays in array.xml for titles and values)
Bostone
  • 36,858
  • 39
  • 167
  • 227
48
votes
4 answers

How can an error message be set for the Spinner in Android?

I'd like to be able to call code like this, similar to how setError is set on a TextView: spinner.setError("Error message"); However, setError only works for an EditText, not for a Spinner. I want to notify the user if the spinner field is not…
Gopinath S
  • 518
  • 1
  • 4
  • 12
45
votes
14 answers

Remove Spacing or Padding in android Spinner

I'm using android spinner and edittext from support lib v21. I would like to align text to left the same like edittext as shown in figure. But, deafult spinner include spacing or padding. So, I would like to remove it to align text to left. Please…
BomberBus
  • 1,195
  • 3
  • 15
  • 29
44
votes
6 answers

Android: two Spinner onItemSelected()

I have two spinners (day_spin and time_spin) in one Activity. I want to save the selected day_spin value into a variable. Is it possible to differenciate between the two spinners in the same Listener? Or do I have to write my own Listener class for…
JavaNullPointer
  • 1,199
  • 5
  • 21
  • 43
43
votes
5 answers

Multiple spinners and onItemSelected

I have two spinners that trigger the onItemSelected event. The question is How can I know which one triggered such event ? So far I tried: public void onItemSelected(AdapterView parent, View view, int position, long id) { …
xain
  • 13,159
  • 17
  • 75
  • 119
42
votes
8 answers

How to create android spinner without down triangle on the right side of the widget

I have a screen where the user has many items to input so screen space is at a premium. I want the look of the widget on the screen (before the user presses it) to be similar to an EditText or the left portion of the Spinner widget (without the…
Mike
  • 777
  • 3
  • 7
  • 14
41
votes
7 answers

Setting a spinner onClickListener() in Android

I'm trying to get an onClickListener to fire on a Spinner, but I get the following error: Java.lang.RuntimeException is "Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead," I'm sure I want to call…
blindstuff
  • 18,298
  • 10
  • 47
  • 48
40
votes
4 answers

Add a spinner when Mat-table is loading?

I load the data in my material table like that : ngOnInit(){ return this.annuairesService.getMedecins().subscribe(res => this.dataSource.data = res);} I want show the spinner when is loading : I try : …
Newbiiiie
  • 1,401
  • 3
  • 14
  • 33
39
votes
13 answers

How to disable onItemSelectedListener to be invoked when setting selected item by code

Just wondering how you handle the following problem: a result is calculated depending on two spinners' selected items. To handle the UI things, i.e. a user picks a new item in one of the spinners, I install a listener using setOnItemSelectedListener…
Zordid
  • 10,451
  • 11
  • 42
  • 58