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

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


int

getBaseline()

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

CharSequence getPrompt() 返回对话框弹出的时候上面标题文字
void onClick(DialogInterfacedialog, 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(SpinnerAdapteradapter) 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.OnItemClickListenerl)

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

void setPrompt(CharSequenceprompt) 设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字) 参数 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.

更多相关文章

  1. Android启动画面实现
  2. Android四大基本组件介绍与生命周期
  3. Android: 如何利用Handler、Thread更新视图
  4. android基础之RelativeLayout布局
  5. Android(安卓)4编程入门经典—开发智能手机与平板电脑应用
  6. Android(安卓)WebView
  7. Android(安卓)增量更新实例(Smart App Updates)
  8. android ksoap调用天气预报
  9. Android(安卓)- Android(安卓)Studio 安装 及 设置 [最新]

随机推荐

  1. Android(安卓)、 WP 7 、IOS
  2. 从 android sqlite 中获取boolean值
  3. android子线程中刷新界面控件
  4. Android 控件的显示和隐藏
  5. Android WebView中的JavaScript调用andro
  6. 切换选项卡
  7. Android 轮询实现的三种方式
  8. android开源工程
  9. Android系统属性SystemProperties.set/ge
  10. 编译V8静态库 for Android