Code example for ToggleButton

Methods: isChecked

0
	private OnClickListener mTogListener = new OnClickListener() {
		public void onClick(View v) { 
			SharedPreferences.Editor editor = mSettings.edit(); 
 
			// Perform action on clicks 
			if (tog.isChecked()) { 
				Toast.makeText(TPController.this, "Pings ON", Toast.LENGTH_SHORT).show(); 
				mRunning = true; 
				editor.putBoolean(KEY_RUNNING, mRunning); 
				setAlarm(); 
			} else { 
				Toast.makeText(TPController.this, "Pings OFF", Toast.LENGTH_SHORT).show(); 
				mRunning = false; 
				editor.putBoolean(KEY_RUNNING, mRunning); 
				cancelAlarm(); 
			} 
			editor.commit(); 
		} 
	};