目录搜索
androidManifestManifest.permissionManifest.permission_groupandroid.accessibilityserviceAccessibilityServiceandroid.accountsAccountandroid.appNotificationManagerandroid.bluetoothBluetoothAdapterBluetoothClassBluetoothClass.DeviceBluetoothClass.Device.MajorBluetoothClass.ServiceBluetoothDeviceBluetoothServerSocketBluetoothSocketandroid.contentSharedPreferencesandroid.database.sqliteSQLiteCursorDriverSQLiteOpenHelperandroid.graphicsBitmapandroid.locationLocationListenerGeocoderGpsStatusGpsStatus.ListenerGpsStatus.NmeaListenerGpsSatelliteandroid.mediaAudioFormatAsyncPlayerAudioRecordAudioRecord.OnRecordPositionUpdateListenerThumbnailUtilsAudioManagerandroid.netTrafficStatsMailToLocalSocketandroid.osAsyncTaskAsyncTask.StatusCountDownTimerMessageMessageQueueHandlerThreadandroid.textHtmlandroid.utilJsonWriterandroid.viewContextMenuContextMenu.ContextMenuInfoDisplayViewManagerViewViewStubViewTreeObserverViewParentWindowManagerGestureDetectorGravityMenuInflaterScaleGestureDetectorSoundEffectConstantsandroid.view.inputmethodInputConnectionInputMethodInputMethodSessionBaseInputConnectionInputMethodManagerandroid.widgetAbsListViewAbsListView.LayoutParamsAbsListView.OnScrollListenerAbsListView.RecyclerListenerAbsoluteLayoutAbsoluteLayout.LayoutParamsAbsSeekBarAbsSpinnerAdapterViewAdapterView.AdapterContextMenuInfoAdapterView.OnItemLongClickListenerAdapterView.OnItemSelectedListenerAdapterView.OnItemClickListenerAnalogClockBaseAdapterBaseExpandableListAdapterButtonCheckBoxCheckedTextViewCheckableChronometerChronometer.OnChronometerTickListenerCompoundButtonCompoundButton.OnCheckedChangeListenerCursorAdapterCursorTreeAdapterDatePickerDatePicker.OnDateChangedListenerDialerFilterDigitalClockEditTextFilterFilter.FilterListenerFilter.FilterResultsExpandableListAdapterExpandableListView.OnChildClickListenerExpandableListView.OnGroupClickListenerExpandableListView.OnGroupCollapseListenerExpandableListView.OnGroupExpandListenerFilterableGalleryGallery.LayoutParamsGridViewGridLayoutGridLayout.AlignmentRadioGroupImageViewImageView.ScaleTypeHorizontalScrollViewImageButtonImageSwitcherFilterQueryProviderListAdapterListViewMediaControllerMultiAutoCompleteTextViewMultiAutoCompleteTextView.CommaTokenizerMultiAutoCompleteTextView.TokenizerQuickContactBadgeRadioButtonRatingBarRatingBar.OnRatingBarChangeListenerRelativeLayoutRemoteViewsResourceCursorAdapterResourceCursorTreeAdapterScrollerScrollViewSearchViewSearchView.OnCloseListenerSearchView.OnQueryTextListenerSearchView.OnSuggestionListenerSeekBarSeekBar.OnSeekBarChangeListenerSimpleAdapterSimpleAdapter.ViewBinderSimpleCursorAdapterSimpleCursorAdapter.CursorToStringConverterSimpleCursorAdapter.ViewBinderSimpleCursorTreeAdapterSimpleCursorTreeAdapter.ViewBinderSimpleExpandableListAdapterSlidingDrawerSlidingDrawer.OnDrawerCloseListenerSlidingDrawer.OnDrawerOpenListenerSlidingDrawer.OnDrawerScrollListenerSpinnerSpinnerAdapterWrapperListAdapterTabHostTabHost.TabSpecTextViewTimePickerTimePicker.OnTimeChangedListenerToastTableLayoutTableLayout.LayoutParamsTableRowTableRow.LayoutParamsTabWidgetTextSwitcherToggleButtonTwoLineListItemVideoViewViewAnimatorViewFlipperViewSwitcherViewSwitcher.ViewFactoryZoomButtonsControllerZoomButtonsController.OnZoomListenerZoomButtonZoomControlsdalvik.systemDexFile
文字


ToggleButton

农民伯伯

版本:Android 2.2 r1

 

public class ToggleButton extends CompoundButton

 

java.lang.Object

android.view.View

       android.widget.TextView

              android.widget.Button

                     android.widget.CompoundButton

                            android.widget.ToggleButton

概述

        

         通过一个带有亮度指示同时默认文本为“ON”或“OFF”的按钮显示选中/未选中状态。

 

XML属性

属性名称

描述

android:disabledAlpha

设置按钮在禁用时透明度。

android:textOff

未选中时按钮的文本

android:textOn

选中时按钮的文本

 

公共方法       

         public CharSequence getTextOff ()

         返回按钮未选中时的文本。

                   返回值

                            文本

 

         public CharSequence getTextOn ()

         返回按钮选中时的文本。

                   返回值

                            文本

 

         public void setBackgroundDrawable (Drawable d)

         设置指定的可绘制(译者注:如图片)为背景,或删除背景。如果让背景有边距,这个视图的边距就是背景的边距。然而,当背景被删除时,这个视图的边距不能被触摸。如果需要设置边距,请使用方法setPadding(int, int, int, int)

(译者注:如果设置删除背景整个就不显示了,此外设置背景后选中和被选中的图片也不显示了,如下图:,实现代码:

                   参数

                            d      设置可绘制(译者注:如图片)为背景,或设置为空删除背景。

 

         public void setChecked (boolean checked)

         改变按钮的选中状态。

                   参数

                            checked true让按钮选中,false让按钮不选中

                           

 

         public void setTextOff (CharSequence textOff)

         设置按钮未选中时显示的文本。

                   参数

                            textOff    文本

 

         public void setTextOn (CharSequence textOn)

         设置按钮选中时显示的文本。

                   参数

                            textOn    文本

 

受保护方法

         protected void drawableStateChanged ()

         在视图状态的变化影响到所显示可绘制的状态时调用这个方法。

         确保在覆盖时中调用父类方法(译者注:super. drawableStateChanged ())。

 

         protected void onFinishInflate ()

         XML文件加载视图完成时调用。这个函数在加载的最后阶段被调用,所有的子视图已经被添加。

         即使子类重写了onFinishInflate方法,也应该始终确保调用父类方法(译者注:super. onFinishInflate()),使系统能够调用。


上一篇:下一篇: