为了账号安全,请及时绑定邮箱和手机立即绑定

崩了,unfortunately,My Application has stopped!跪求支援

/ 猿问

崩了,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);

}


查看完整描述

1 回答

?
ewang1986

提供下报错堆栈信息,一般来说,答案就在其中

查看完整回答
反对 回复 2019-01-21

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信