【发布时间】:2016-06-04 13:31:04
【问题描述】:
我想在应用启动次数达到 10 次时展示插页式广告。所以我用
OnCreate{
prefs = getPreferences(Context.MODE_PRIVATE);
editor = prefs.edit();
totalCount = prefs.getInt("counter", 0);
totalCount++;
editor.putInt("counter", totalCount);
editor.commit(); }
每当 totalCount = 10 我运行添加:
if(totalCount==10){
fullScreenAd2.show();
}
现在我想重置 totalCount,我该怎么做?
我知道调用 totalCount++ 会加 1 分,而 totalCount-- 会减 1 分。但是如何将其重置为 0?
【问题讨论】:
-
totalCount = 0 怎么样?
-
不,这不起作用。
-
不确定您的确切要求,但您使用 totalCount=0 重置它..
-
不,这不会重置它。 :(
-
当然可以!