android >ToggleButton(开启/关闭) 控件

			final ToggleButton value4 = (ToggleButton)view.findViewById(R.id.monitor_list_right);
			if(list.get(position).get("data").equals("1")){
				value4.setChecked(true);
			}else{
				value4.setChecked(false);
			}
			//点击事件
			value4.setOnCheckedChangeListener(new OnCheckedChangeListener() {				
				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
					// TODO Auto-generated method stub
					if(value4.isChecked()){//如果toggleButton是on
							
						System.out.println("is checkded");	
						}else{//如果toggleButton是off
						
						System.out.println("is UNcheckded");
						

					}
				}
			});
 

你可能感兴趣的:(android)