spinner(中)

来源:互联网 发布:淘宝装修代码在线 编辑:程序博客网 时间:2024/06/10 02:56

下拉列表(Spinner)是一个每次只能选择所有项中一项的部件。它的项来自于与之相关联的适配器中。XML AttributesAttribute NameRelated MethodDescriptionandroid:gravitysetGravity(int) 设置当前被选中的项目的位置android:prompt在下拉列表对话框显示时显示 intgetBaseline()返回这个控件文本基线的偏移量。如果这个控件不支持基线对齐,那么方法返回-1CharSequencegetPrompt() 返回对话框弹出的时候上面标题文字voidonClick(DialogInterface dialog, int which)This method will be invoked when a button in the dialog is clicked. 当点击弹出框中的项时这个方法将被调用。dialog 点击弹出的对话框   which 点击按钮(如:Button)或者点击位置booleanperformClick()如果它被定义就调用此视图的 OnClickListener (译者注:例如可以在加载时默认弹出下拉列表)。返回值     为True一个指定的OnClickListener被调用,为false时不被调用。voidsetAdapter(SpinnerAdapter adapter)The Adapter is used to provide the data which backs this Spinner.voidsetEnabled(boolean enabled)Set the enabled state of this view. 设置是否能用voidsetGravity(int gravity)Describes how the selected item view is positioned.voidsetOnItemClickListener(AdapterView.OnItemClickListener l)Spinner不支持item的点击事件,调用此方法将引发异常。参数l 这个监听将被忽略voidsetPrompt(CharSequence prompt)设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字) 参数 prompt  设置的提示voidsetPromptId(int promptId)设置对话框弹出的时候显示的提示(译者注:设置弹出视图上的标题字)参数prompt 设置的提示 受保护的方法:Protected MethodsvoidonDetachedFromWindow()This is called when the view is detached from a window.当这个视图从屏幕上卸载时候被调用。在这一点上不再绘制视图。voidonLayout(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 相对父空间的底部位置voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)Measure the view and its content to determine the measured width and the measured height.



0 0
原创粉丝点击