ディレクトリ 検索
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
テキスト


RadioGroup

版本:Android 2.2 r1

 

结构

继承关系

public class RadioGroup extends LinearLayout

        

java.lang.Object

         android.view.View

                   android.view.ViewGroup

                            android.widget.LinearLayout

                                     android.widget.RadioGroup

 

类概述

这个类用于创建一组按钮之间相互排斥的单选按钮组,在同一个单选按钮组中勾选一个按钮则会取消该组中其它已经勾选的按钮的选中状态。

初始状态下,所有的单选按钮都未勾选,虽然不能取消一个特定的单选按钮的勾选状态,但可以通过单选按钮组去消除它的勾选状态,根据XML布局文件中的单选按钮的唯一ID去标识指定的选择信息。

 

内部类

Class               RadioGroup.LayoutParams    

WRAP_CONTENT(包裹内容)的子组件在XML文件中没有指定相应的宽度和高度的话,可以使用的布局参数默认设置的默认设置

 

Interface         RadioGroup.OnCheckedChangeListener

当单选按钮组中的单选按钮的勾选状态发生改变时,所要调用的回调函数的接口类

 

公共方法

public void addView (View child, int index, ViewGroup.LayoutParams params)

         使用指定的布局参数添加一个子视图

参数

                            child         所要添加的子视图

index         将要添加子视图的位置

params    所要添加的子视图的布局参数

                           

public void check (int id) 

        如果传递-1作为指定的选择标识符来清除单选按钮组的勾选状态,相当于调用clearCheck()操作

参数

                            id     该组中所要勾选的单选按钮的唯一标识符(id

                   参见

                            getCheckedRadioButtonId()

                            clearCheck()

 

public void clearCheck () 

清除当前的选择状态,当选择状态被清除,则单选按钮组里面的所有单选按钮将取消勾选状态,getCheckedRadioButtonId()将返回null

                   参见

                            check(int)

                            getCheckedRadioButtonId()

 

public RadioGroup.LayoutParams generateLayoutParams (AttributeSet attrs)   

基于提供的属性集合返回一个新的布局参数集合

参数

                            attrs                   用于生成布局参数的属性

                   返回值

                            返回一个ViewGroup.LayoutParams或其子类的实例

 

public int getCheckedRadioButtonId ()  

返回该单选按钮组中所选择的单选按钮的标识ID,如果没有勾选则返回-1

                   返回值

                            返回该单选按钮组中所选择的单选按钮的标识ID

                   参见

                            check(int)

clearCheck()

 

public void setOnCheckedChangeListener (RadioGroup.OnCheckedChangeListener listener)

注册一个当该单选按钮组中的单选按钮勾选状态发生改变时所要调用的回调函数

参数

                            listener    当单选按钮勾选状态发生改变时所要调用的回调函数

                           

public void setOnHierarchyChangeListener (ViewGroup.OnHierarchyChangeListener listener)

注册一个当子内容添加到该视图或者从该视图中移除时所要调用的回调函数

参数

                            listener    当层次结构发生改变时所要调用的回调函数

 

受保护方法

protected LinearLayout.LayoutParams generateDefaultLayoutParams ()

当布局为垂直方向时,将返回一个宽度为“填充父元素”(MATCH_PARENT),高度为“包裹内容”的布局参数集合,如果为水平方向时,将返回宽度为“包裹内容”,高度为“填充父元素”的布局参数集合

(match_parent即为fill_parent,public static final int FILL_PARENT/MATCH_PARENT = -1 )

                   返回值

返回一个默认的布局参数集合

 

protected void onFinishInflate ()

当视图从XML中加载,且相应的子视图被添加之后,调用该方法,

即使子类重写了该方法,应该确保去调用父类的方法(通常放在方法在第一句),这样才能完成相应的调用参数

                   返回值

返回一个默认的布局参数集合

 

补充

文章链接

Android基础教程()----单选项框RadioGroup的综合应用

Android UI设计 RadioGroup单选按钮用法

Android 小項目之--猜名字有獎!RadionButton RadionGroup應用(附源碼)

示例代码        


前の記事: 次の記事: