我和老师代码一样,为什么我的会报错?
package com.example.test4;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View.OnClickListener;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.ToggleButton;
public class MainActivity extends Activity implements OnCheckedChangeListener{
private ToggleButton tog;
private ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tog=(ToggleButton) findViewById(R.id.toggleButton1);
img=(ImageView) findViewById(R.id.imageView1);
tog.setOnCheckedChangeListener(this);
}
// @Override
// public boolean onCreateOptionsMenu(Menu menu) {
// // Inflate the menu; this adds items to the action bar if it is present.
// getMenuInflater().inflate(R.menu.main, menu);
// return true;
// }
// @Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
img.setBackgroundResource(isChecked?R.drawable.on:R.drawable.off);
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
}
}