2014-01-09 43 views
0

我正在做一個應用程序,我正在使用警報對話框,但是當我按下按鈕並旋轉後,警報對話框再次彈出。我試圖做到這一點,但沒有奏效。我真的很感激,如果有人可以幫助...每當我旋轉彈出警報對話框

AlertDialog.Builder builder = new AlertDialog.Builder(this); 

    builder.setTitle("Alert Dialog") 
    .setMessage("Startup Button Visibility:") 
    .setPositiveButton("Hidden", new DialogInterface.OnClickListener() { 
     @Override 
     public void onClick(DialogInterface dialog, int which) { 
      if(buttonVisible == true) 
      { 
       myLayout2.setVisibility(View.INVISIBLE); 
      } 
      else 
       myLayout2.setVisibility(View.VISIBLE); 


      SharedPreferences myPrefs = getPreferences(MODE_PRIVATE); 
      boolean storedPreference = myPrefs.getBoolean("Skip", true); 
      SharedPreferences.Editor editor = myPrefs.edit(); 
      if(storedPreference != false) 
      { 
       storedPreference= true; 
      } 
      editor.putBoolean("Skip", storedPreference); 
      editor.commit(); 
     } 
    }) 

    .show(); 

回答