我想用切换按钮控制手机的全屏。我做到了,但它只工作一次。我该如何解决?有代码:
final ToggleButton toggle_button_for_full_screen = (ToggleButton) findViewById(R.id.toggleButton1);
toggle_button_for_full_screen.setOnCheckedChangeListener(new OnCheckedChangeListener() {
boolean variable_for_saving_toggle_button_status;
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
if (isChecked)
{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
else
{
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
}
});