I have a little problem, and now I'm working with a toggle button, and the first toggle button is for day or night indication, and the second toggle button is to turn on or off the light. Then my requirement is when the day comes, and the second switch button should not work, and then when the final switch button should work, and this should indicate whether the indicators are on. And my code
final ToggleButton tb = (ToggleButton) findViewById(R.id.togglebutton); tb.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button is "+tb.getText().toString(), Toast.LENGTH_LONG).show(); if(tb.getText().toString().equals("ON")) { final ToggleButton tb1= (ToggleButton) findViewById(R.id.togglebutton1); tb1.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(getBaseContext(), "Button is "+tb1.getText().toString(), Toast.LENGTH_LONG).show(); }}); } else { Toast.makeText(screen4.this,"It is day" , Toast.LENGTH_LONG).show(); finish(); } } });
Can someone help me make the second button not work when the first button is off. thanks in advance
source share