2012-04-13 79 views
-2

我不知道如何:不再顯示提醒

每次用戶啓動應用程序時都會顯示一條提醒。

當用戶選擇該選項。 「不再顯示。」怎麼不顯示更多?沒有數據庫的地方保存這些信息?簡單?

我該怎麼做?選擇該選項時,我已保存在緩存中?我現在還不明白。 非常感謝你

感謝

+0

他「沒有再顯示」?這條線不清楚你想說什麼 – 2012-04-13 11:05:04

+0

你可以在數據庫或文件中存儲「不再顯示」 – 2012-04-13 11:10:08

回答

0

做到在第一屏的onCreate()方法...

以及維持其狀態..創建一個類,並保持一個變量,並創建靜態getter和干將..設置它時,他說不再顯示我..並檢查每次顯示前..

+0

更多當用戶選擇不再想看到的選項時,如何不顯示更多警報。 例如:「不要再顯示」 – GDawson 2012-04-13 11:05:01

+0

@GDawson ..查看我的編輯 – ngesh 2012-04-13 11:08:21

0

你可以記錄當用戶啓動你的應用程序在onCreate(),然後只顯示警報,如果沒有設置。所以,這樣的事情。

public class MyClass extends Activity { 
    boolean alreadyOpened = false; 
    boolean doNotShowAgain; 

    public void onCreate(Bundle savedInstanceState) { 

     doNotShowAgain = loadFromPreferences(); 

     if(!alreadyOpened || !doNotShowAgain) { 
      showDialog(MYDIALOG); 
      alreadyOpened = true; 
     } 

     //your code goes here 

    } 

} 

然後,你需要編寫代碼來加載「沒有不再顯示」 preferencemore

0

您可以使用下面的代碼在它

SharedPreferences prefs; 
      prefs= this.getSharedPreferences("yourprefName",0); 
     Editor editor = prefs.edit(); 
       editor.putString("yourtag", "information"); 
       editor.commit(); 
and Get information like 
String info=prefs.getString("yourtag", null); 

數據存儲共享偏好更多信息 How do I get the SharedPreferences from a PreferenceActivity in Android?this一個