Preface
This chapter content is android. widget. AbsSpinner, version for Android 2.2 r1, translation from "think Wolf", welcome to visit his blog: http://blog.163.com/sikaodelang@126/, thanks again "think Wolf "! I look forward to your participation in Android API Chinese translation, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog Garden: http://www.cnblogs.com/
Android Chinese translation group: http://www.cnblogs.com/over140/
Body
I. Structure
Public abstract class AbsSpinner extends AdapterView <T extends Adapter>
Java. lang. Object
Android. view. View
Android. view. ViewGroup
Android. widget. AdapterView <T extends android. widget. Adapter>
Android. widget. AbsSpinner
Ii. Overview
The base class of the drop-down list. The Sdk may no longer use this class)
Iii. XML attributes
Attribute name |
Description |
Android: entries |
Reference a data source to fill in the Spinner. For static content, this is a simpler method than programming to populate the Spinner. |
Iv. Public Methods
Public SpinnerAdapter getAdapter ()
Returns the adapter associated with the current part.
Return Value
This adapter is used to provide View content
Public int getCount ()
Return Value
The number of projects that the adapter AdapterView has. (This data item may be larger than the data volume in the displayed view .)
Public View getSelectedView ()
Return Value
This view corresponds to the currently selected item, or null if no view is selected
Public void onRestoreInstanceState (Parcelable state)
Allows the view to be re-applied. Previously, onSaveInstanceState () was used to generate an internal state. This function cannot be called with a null value.
Parameters
The state returns the status that was previously saved by calling onSaveInstanceState.
Public Parcelable onSaveInstanceState ()
Allows the view to generate an internal status, which can be used to create a new instance with the same status. This status can only contain information that is temporary or cannot be rebuilt. For example, you cannot save your current position on the screen, because when a new object appears at this view level, it is automatically recalculated.
Some examples are as follows: when the cursor stays in a text area (but generally it cannot be a real document because it is stored in the content provider or other persistent storage devices ), the currently selected item is in a list view.
Return Value
Returns a Parcelable object that contains the dynamic status of the current view, or returns null. If it is not saved, the default return value is null.
Public int pointToPosition (int x, int y)
Maps to a coordinate in the list (the Translator's note: Based on this coordinate, you can determine which item to click. here)
Parameters
X local coordinate X)
Y local coordinate Y)
Return Value
Returns the specified vertex contained in this position (Note: returns the order of coordinates (items) in the list). If the two vertices do not intersection, returns INVALID_POSITION.
Public void requestLayout ()
Rewrite to prevent a large number of layout requirements in the Layout View. (Note: This method is usually called when the view thinks it is no longer suitable for its current boundary)
Public void setAdapter (SpinnerAdapter adapter)
This adapter is used to provide data support for this Spinner. He also provides options for changing relative positions based on their selection.
Parameters
Adapter this SpinnerAdapter is used for the drop-down list
Public void setSelection (int position, boolean animate)
Directly jump to the specified item in the data adapter
Public void setSelection (int position)
Set the currently selected item. To support accessible subclass rewriting, you must first call the method of the parent class.
Parameters
Position Index, selected data items (starting from 0)
5. Protected Methods
Protected ViewGroup. LayoutParams generateDefaultLayoutParams ()
Return the default layout parameters. These parameters are set when the request is passed to addView (View) without layout. If null is returned, an exception is thrown from addView.
Return Value
Default parameter layout or null