我不知道如何:不再顯示提醒
每次用戶啓動應用程序時都會顯示一條提醒。
當用戶選擇該選項。 「不再顯示。」怎麼不顯示更多?沒有數據庫的地方保存這些信息?簡單?
我該怎麼做?選擇該選項時,我已保存在緩存中?我現在還不明白。 非常感謝你
感謝
我不知道如何:不再顯示提醒
每次用戶啓動應用程序時都會顯示一條提醒。
當用戶選擇該選項。 「不再顯示。」怎麼不顯示更多?沒有數據庫的地方保存這些信息?簡單?
我該怎麼做?選擇該選項時,我已保存在緩存中?我現在還不明白。 非常感謝你
感謝
你可以記錄當用戶啓動你的應用程序在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
您可以使用下面的代碼在它
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一個
他「沒有再顯示」?這條線不清楚你想說什麼 – 2012-04-13 11:05:04
你可以在數據庫或文件中存儲「不再顯示」 – 2012-04-13 11:10:08