Android Spinner

下拉列表(Spinner)是一个每次只能选择全部项中一项的部件。它的项来自于与之相关联的适配器中。html

XML Attributes
Attribute Name Related Method Description
android:gravity setGravity(int)  设置当前被选中的项目的位置
android:prompt 在下拉列表对话框显示时显示

 


intjava

getBaseline()

返回这个控件文本基线的偏移量。若是这个控件不支持基线对齐,那么方法返回-1android

CharSequence getPrompt() 返回对话框弹出的时候上面标题文字
void onClick(DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked.

 当点击弹出框中的项时这个方法将被调用。ide

dialog 点击弹出的对话框   which 点击按钮(如:Button)或者点击位置布局

boolean performClick()
若是它被定义就调用此视图的 OnClickListener (译者注:例如能够在加载时默认弹出下拉列表)。

返回值     True一个指定的OnClickListener被调用,为false时不被调用。this

void setAdapter(SpinnerAdapter adapter)
The Adapter is used to provide the data which backs this Spinner.
void setEnabled(boolean enabled)
Set the enabled state of this view. 设置是否能用
void setGravity(int gravity)
Describes how the selected item view is positioned.
void setOnItemClickListener(AdapterView.OnItemClickListener l)

Spinner不支持item的点击事件,调用此方法将引起异常。参数l 这个监听将被忽略spa

void setPrompt(CharSequence prompt)
设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字) 参数 prompt  设置的提示
void

setPromptId(int promptId)orm

设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字)参数prompt 设置的提示htm

 受保护的方法:对象

Protected Methods
void onDetachedFromWindow()
This is called when the view is detached from a window.
当这个视图从屏幕上卸载时候被调用。在这一点上再也不绘制视图。
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.

View要为全部子对象分配大小和位置时,调用此方法。派生类与子项们应该重载这个方法和调用布局每个子项。

参数changed 这是这个视图的一个新的大小或位置

l 相对父空间的左位置   t 相对父空间的顶端位置   r 相对父空间的右端位置   b 相对父空间的底部位置

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

相关文章
相关标签/搜索