Code example for ToggleButton

Methods: setOnCheckedChangeListenersetCheckedsetTextOffsetTextOn

0
				break; 
			/* Switch (open/close) */ 
			case 3: 
				bu = new AlertDialog.Builder(MainActivity.this);
				bu.setTitle ("Switch");
				ToggleButton tb = new ToggleButton (MainActivity.this);
				tb.setTextOff("Close");
				tb.setTextOn("Open");
				tb.setChecked(open);
				bu.setView(tb);
				tb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener () {
					public void onCheckedChanged (CompoundButton buttonView, boolean isChecked) {
						if ((!isChecked && open) || (isChecked && !open)) {
							Toast t=Toast.makeText(MainActivity.this, "LOL", Toast.LENGTH_SHORT);
							t.show();
							changeWindowStatus (isChecked);
						} 
						/* Funny Stuff happens here :D */ 
					} 
				}); 
Stop searching for code, let great code find you!  Add Codota to your java IDE