当前位置:操作系统 > 安卓/Android >>

Android Spinner

 

下拉列表(Spinner)是一个每次只能选择所有项中一项的部件。它的项来自于与之相关联的适配器中。
XML Attributes
Attribute Name Related Method Description
android:gravity
setGravity(int)
 设置当前被选中的项目的位置
android:prompt
 在下拉列表对话框显示时显示
 

int getBaseline()www.zzzyk.com
返回这个控件文本基线的偏移量。如果这个控件不支持基线对齐,那么方法返回-1
CharSequence
getPrompt() 返回对话框弹出的时候上面标题文字

void onClick(DialogInterface dialog, int which)
This method will be invoked when a button in the dialog is clicked.
 当点击弹出框中的项时这个方法将被调用。
dialog 点击弹出的对话框   which 点击按钮(如:Button)或者点击位置
boolean performClick()
如果它被定义就调用此视图的 OnClickListener (译者注:例如可以在加载时默认弹出下拉列表)。
返回值     为True一个指定的OnClickListener被调用,为false时不被调用。
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 这个监听将被忽略
void setPrompt(CharSequence prompt)
设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字) 参数 prompt  设置的提示
void setPromptId(int promptId)
设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字)参数prompt 设置的提示
 受保护的方法:
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.
 

  作者:amigos_pop

补充:移动开发 , Android ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,