我这里用匿名内部类不行呢!!老师,还有高手帮我看下,谢谢了
package com.example.lianxi2;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;//把这个删除,导入RadioGroup的还是不行,因为我中间有个程序要用,删了,另一个又出错,不删,又导不进去,求告知啊
import android.widget.RadioGroup;
public class MainActivity extends Activity {
private CheckBox CB;
private RadioGroup rg;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CB = (CheckBox) findViewById(R.id.checkBox1);
CB.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO 自动生成的方法存根
if(isChecked){
String text = CB.getText().toString();
Log.i("tag", text);
}
}
});
rg = (RadioGroup) findViewById(R.id.radioGroup1); //这里总提示有错啊
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() { //这里总提示有错啊
@Override
public void onCheckedChanged(RadioGroup arg0, int arg1) {
// TODO 自动生成的方法存根
}
});
}}