首页>代码>android电灯开关效果实例>/Kd/src/jmi/mi/KD/Main.java
package jmi.mi.KD;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ToggleButton;
import android.widget.CompoundButton;
public class Main extends Activity implements CompoundButton.OnCheckedChangeListener {
	/** Called when the activity is first created. */
	
	private ToggleButton toggleButton;
    private ImageView imageView;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		toggleButton = (ToggleButton) findViewById(R.id.togbutton);
        imageView = (ImageView) findViewById(R.id.q2);
        toggleButton.setOnCheckedChangeListener(this);
	}
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		// TODO Auto-generated method stub
		toggleButton.setChecked(isChecked);
        imageView.setImageResource(isChecked ? R.drawable.q2 : R.drawable.q1);
	}
}
最近下载更多
2636804923  LV6 2024年6月19日
sfgj22  LV1 2022年5月17日
坚果  LV1 2021年10月6日
梦本是很好的啦  LV11 2021年9月26日
wyxz123  LV1 2021年8月5日
a566566  LV9 2020年12月29日
Zombie丶  LV1 2020年10月8日
zzzxxcc  LV6 2020年6月17日
1205086421  LV1 2019年12月12日
最麦兜  LV7 2019年10月24日
最近浏览更多
2636804923  LV6 2024年6月19日
AIWU1234  LV2 2024年6月9日
lilitu  LV6 2024年5月30日
yeeshao 2023年9月20日
暂无贡献等级
yyyyyyzh  LV8 2023年6月11日
YiyiiiRTRTH  LV1 2022年11月23日
uni-code_0123  LV1 2022年11月3日
kezai520  LV1 2022年9月8日
406503223  LV5 2022年6月8日
alexstory  LV6 2022年6月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友