2015-11-02 15 views
0

我想在移動應用程序的所有進程完成時公開隱藏菜單,並且該菜單必須始終顯示,即使應用程序已關閉並重新啓動。當移動應用程序的所有進程已完成時,我想要展示隱藏的菜單

我以爲即使應用程序關閉,剩下的價值,但我不知道該怎麼做。讓我知道如何解決這個問題。

public class Intro extends Activity implements View.OnClickListener{ 
    private final boolean notCleared = false;  
    private final boolean cleared = true;  
    private boolean status; 

    private Button start; 
    private Button what; 
    private Button hidden; 
    private Intent intent; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.activity_intro); 

     start = (Button) findViewById(R.id.startButton); 
     what = (Button) findViewById(R.id.whatButton); 
     hidden = (Button) findViewById(R.id.hiddenButton); 

     >>if(status) hidden.setVisibility(View.Visible);<< 

     start.setOnClickListener(this); 
     what.setOnClickListener(this); 
    } 
} 
+1

閱讀本[文件](http://developer.android.com/guide/topics/data/data-storage.html),回來這裏更多具體的問題(包括一些代碼,以顯示你迄今爲止嘗試過的) – 0X0nosugar

+0

「這個菜單」在哪裏? ['Shared Shared>](https://developer.android.com/reference/android/content/SharedPreferences.html)可能是一個開始尋找的地方。 –

+0

@ 0X0nosugar我想應用程序有值**布爾值notCleared = false,布爾值清除= true,布爾狀態=不清除**,我想設置**狀態=清除**當我清除應用程序的所有進程。並且即使應用程序關閉,** status **值也不會被更改。我不擅長英語,所以對於一些奇怪的句子感到抱歉... –

回答

0

我用SharedPreferences解決了這個問題。 感謝0x0nosugar和肯YN :-)

public class Intro extends Activity implements View.OnClickListener{ 
    private boolean isCleared; 

    private Button start; 
    private Button what; 
    private Button hidden; 
    private Intent intent; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     this.requestWindowFeature(Window.FEATURE_NO_TITLE); 
     setContentView(R.layout.activity_intro); 

     start = (Button) findViewById(R.id.startButton); 
     what = (Button) findViewById(R.id.whatButton); 
     hidden = (Button) findViewById(R.id.hiddenButton); 

     SharedPreferences prefs = getSharedPreferences("isCleared", MODE_PRIVATE); 

     //If someone complete all of processes, 
     //SharedPreferences prefs = getSharedPreferences("isCleared", MODE_PRIVATE); 
     //SharedPreferences.Editor editor = prefs.edit(); 
     //editor.putBoolean("isCleared", true); 
     //editor.commit(); 

     if(isCleared) 
      hidden.setVisibility(View.VISIBLE); 

     start.setOnClickListener(this); 
     what.setOnClickListener(this); 
    } 
} 
相關問題