安卓_5

监听器

OnClickListener

OnChecjedChangeListener

//===========

1、单选按钮的基本概念

2、radiogrounp与radiobutton

3、onClickListener与OnCheckedChangeListener监听器

//=====================

什么是Radio

1.XML文件:

<RadioButton/>&<radioGroup/>

2.代码RadioButton&RadioGroup//findViewById

3.常用OnClickListener与OnChecked\ChangeListerner监听器

//==========================

<Linerlayout>

android:orientation = "vertical"

<RadioGroup

 

  android:orientation ="horital"

 

    <RadioButton

 

 

 

      />

    <RadioButton

 

 

      />

 

 

/RadioGroup>//有子标签

<TextView />无

//==========================

->MainActivity

private RadioGroup radioGroup;

private RadioBUtton femaleButton;

private RadioBUtton malebutton;

 

RadioGroupListener listener = new RadioGroupListener();

radioGroup.setOnCheckedChangeListener(listener);

 

//===================

绑定监听器

class RadioGroupListener implents OnCheckedChangeListener{

public void onCheckedChanged(RadioGroup group,int checkId)

{

//==========Id 是R.java中生成的

   if(checkedId == famaleButton.getId()){

    System.out.println("");  

}else{

}

 

 

 

}

}

}

 //=====================

class RadioButtonListener implements android.widget.compoundButton.OnCheckedChangeListener{

public void onCheckedChanged(CompoundButton button,boolean isChecked)

{

}

}

//==========================

RadioButtonListener radionBUttonListener = new RadioButtonListener();

femaleButton.setOnCheckedChangeListener(radioButtonListener);

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。