您的位置:首页 > 移动开发 > Android开发

Android7.0中文文档(API) --- ToggleButton

2017-06-12 00:41 579 查看

完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/ToggleButton.html

ToggleButton

public class ToggleButton

extends

CompoundButton


java.lang.Object
   ↳android.view.View
    ↳android.widget.TextView
     ↳android.widget.Button
      ↳android.widget.CompoundButton
       ↳android.widget.ToggleButton
Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".

带“光亮”指示器的按钮,其显示选中/未选中状态,并且默认情况下,还在按钮上显示“ON”或“OFF”文本。

See the
Toggle Buttons guide.

请参考Toggle Buttons

摘要

XML属性

android:disabledAlpha
当被禁用时,此alpha值将应用于指示器。 
android:textOff
当没有被选中时,按钮的文本。 
android:textOn
当被选中时,按钮的文本。 

继承XML属性



From
class
android.widget.CompoundButton




From
class
android.widget.TextView




From
class
android.view.View


继承常量



From
class
android.widget.TextView




From
class
android.view.View


继承字段



From
class
android.view.View


Public构造方法

ToggleButton(Context
context,
AttributeSet attrs, int defStyleAttr, int defStyleRes)
ToggleButton(Context
context,
AttributeSet attrs, int defStyleAttr)
ToggleButton(Context
context,
AttributeSet attrs)
ToggleButton(Context
context)

Public方法

CharSequence
getAccessibilityClassName()

Return the class name of this object to be used for accessibility purposes.

返回此对象的类名,用于辅助功能目的。

CharSequence
getTextOff()

Returns the text for when the button is not in the checked state.

返回按钮在非选中状态设置文本。

CharSequence
getTextOn()

Returns the text for when the button is in the checked state.

返回按钮在非选中状态设置文本。

void
setBackgroundDrawable(Drawable
d)

This method is deprecated. use
setBackground(Drawable)
instead

此方法已取消,使用
setBackground(Drawable)
替代。

void
setChecked(boolean checked)

Changes the checked state of this button.

设置此按钮的选中状态。

void
setTextOff(CharSequence
textOff)

Sets the text for when the button is not in the checked state.

为按钮在非选中状态设置文本。

void
setTextOn(CharSequence
textOn)

Sets the text for when the button is in the checked state.

为按钮在选中状态设置文本。

保护方法

void
drawableStateChanged()

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

每当视图状态发生变化时, 都会调用此方法, 从而影响所显示的drawable的状态。

void
onFinishInflate()

Finalize inflating a view from XML.

完成从XML中加载(inflate)的视图。

继承方法

完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/ToggleButton.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息