public class

Spinner

extends AbsSpinner
implements DialogInterface.OnClickListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AdapterView<T extends android.widget.Adapter>
         ↳ android.widget.AbsSpinner
           ↳ android.widget.Spinner

Class Overview

A view that displays one child at a time and lets the user pick among them. The items in the Spinner come from the Adapter associated with this view.

Summary

XML Attributes
Attribute Name Related Method Description
android:prompt The prompt to display when the spinner's dialog is shown. 
[Expand]
Inherited XML Attributes
From class android.widget.AbsSpinner
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View
Public Constructors
Spinner(Context context)
Spinner(Context context, AttributeSet attrs)
Spinner(Context context, AttributeSet attrs, int defStyle)
Public Methods
int getBaseline()

Return the offset of the widget's text baseline from the widget's top boundary.

CharSequence getPrompt()
void onClick(DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked.
boolean performClick()
Call this view's OnClickListener, if it is defined.
void setOnItemClickListener(AdapterView.OnItemClickListener l)

A spinner does not support item click events.

void setPrompt(CharSequence prompt)
Sets the prompt to display when the dialog is shown.
void setPromptId(int promptId)
Sets the prompt to display when the dialog is shown.
Protected Methods
void onLayout(boolean changed, int l, int t, int r, int b)
Called from layout when this view should assign a size and position to each of its children.
[Expand]
Inherited Methods
From class android.widget.AbsSpinner
From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.content.DialogInterface.OnClickListener
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent

XML Attributes

android:prompt

The prompt to display when the spinner's dialog is shown.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol prompt.

Related Methods

Public Constructors

public Spinner (Context context)

public Spinner (Context context, AttributeSet attrs)

public Spinner (Context context, AttributeSet attrs, int defStyle)

Public Methods

public int getBaseline ()

Return the offset of the widget's text baseline from the widget's top boundary. If this widget does not support baseline alignment, this method returns -1.

Returns
  • the offset of the baseline within the widget's bounds or -1 if baseline alignment is not supported

public CharSequence getPrompt ()

Returns
  • The prompt to display when the dialog is shown

public void onClick (DialogInterface dialog, int which)

This method will be invoked when a button in the dialog is clicked.

Parameters
dialog The dialog that received the click.
which The button that was clicked (e.g. BUTTON1) or the position of the item clicked.

public boolean performClick ()

Call this view's OnClickListener, if it is defined.

Returns
  • True there was an assigned OnClickListener that was called, false otherwise is returned.

public void setOnItemClickListener (AdapterView.OnItemClickListener l)

A spinner does not support item click events. Calling this method will raise an exception.

Parameters
l this listener will be ignored

public void setPrompt (CharSequence prompt)

Sets the prompt to display when the dialog is shown.

Parameters
prompt the prompt to set

public void setPromptId (int promptId)

Sets the prompt to display when the dialog is shown.

Parameters
promptId the resource ID of the prompt to display when the dialog is shown

Protected Methods

protected void onLayout (boolean changed, int l, int t, int r, int b)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their their children.

Parameters
changed This is a new size or position for this view
l Left position, relative to parent
t Top position, relative to parent
r Right position, relative to parent
b Bottom position, relative to parent