我正在我的应用程序中实现RadioGroup。为此,我已导入import android.widget.RadioGroup
和implemented OnCheckedChangeListener
. 但我仍然收到此错误:
RadioGroup 类型中的方法 setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener) 不适用于参数 (OpenedClass)
爪哇:
OpenedClass.java
public class OpenedClass extends Activity implements OnClickListener,OnCheckedChangeListener{
TextView tv1,tv2;
RadioGroup selectionList;
Button rtn;
String gotBread;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.send);
initlize();
Bundle gotBusket = getIntent().getExtras();
gotBread = gotBusket.getString("KEY");
tv1.setText(gotBread);
}
private void initlize() {
// TODO Auto-generated method stub
tv1 = (TextView)findViewById(R.id.tvQuestion);
tv2 = (TextView)findViewById(R.id.textView2);
rtn = (Button)findViewById(R.id.bReturn);
rtn.setOnClickListener(this);
selectionList = (RadioGroup)findViewById(R.id.rgAnswers);
selectionList.setOnCheckedChangeListener(this);
}
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
}
@Override
public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
// TODO Auto-generated method stub
switch(arg0.getId())
{
case R.id.rCrazy:
break;
case R.id.rSuper:
break;
case R.id.rBoth:
break;
}
}
}