崩了,unfortunately,My Application has stopped!跪求支援
public class MainActivity extends Activity implements OnCheckedChangeListener{
private ToggleButton but1;
private ImageView ima1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
but1 =(ToggleButton) findViewById(R.id.toggleButton1);
ima1 = (ImageView) findViewById(R.id.imageView1);
but1.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 buttonviwe, boolean isChecked) {
// TODO Auto-generated method stub
ima1.setBackgroundResource(isChecked?R.drawable.on:R.drawable.off);
} |
免责声明:本内容仅代表回答会员见解不代表天盟观点,请谨慎对待。
版权声明:作者保留权利,不代表天盟立场。
|
|
|
|