首页 \ 问答 \ 共享偏好不相似(shared preference not similar)

共享偏好不相似(shared preference not similar)

我有两个修改共享首选项文件的onclick操作:

int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter++;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();

int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter--;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();

但是当第一个被重新执行时,它需要它的旧值。


I have two onclick actions that modifies a shared preference file :

int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter++;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();

and

int value = counters.getInt("wcounter", 0);
wcounter = value;
wcounter--;
Editor editor = counters.edit();
editor.putInt("wcounter", wcounter);
editor.commit();

but when the first one is re executed it takes it's old value.


原文:https://stackoverflow.com/questions/18433618
更新时间:2023-07-07 06:07

最满意答案

您需要导出数据模块。 它使用downloadCSV方法扩展图表。

function downlaodCsv() {
  chart.downloadCSV()
}

现场示例: http : //jsfiddle.net/z1j4enox/


You need the export-data module. It extends a chart with downloadCSV method.

function downlaodCsv() {
  chart.downloadCSV()
}

live example: http://jsfiddle.net/z1j4enox/

相关问答

更多
  • 我的解决方法: 我只是在highcharts-export-csv.js的内容下面粘贴了highcharts-exporting.js和highcharts-export-csv.js的highcharts.js 。 因此我的define行只是: define(['jquery', 'jquery.spectrum', '../lib/highcharts.js'], function($) { My workaround: I just pasted the contente of highcharts- ...
  • 我在代码中看到date变量是一个字符串: // all data lines start with a double quote line = line.split(','); date = line[1] + " " + line[2]; (...) RTC.push([ date, parseI ...
  • 在该示例中,他们将xAxis.categories推送到空数组列中。 然后,他们在列的第一个元素上使用unshift,这也是xAxis.categories。 与其他返回修改后的数组的函数不同,unshift会修改它所使用的数组。 列中的元素是对xAxis.categories的同一对象的引用,因此它正在修改该数组。 如果你在jsFiddle上调整窗格大小,触发图表重绘,这将是显而易见的。 所有这些都适用于series.yData。 他们需要做的是制作xAxis.categories数组和series.yD ...
  • 您需要导出数据模块。 它使用downloadCSV方法扩展图表。 function downlaodCsv() { chart.downloadCSV() } 现场示例: http : //jsfiddle.net/z1j4enox/ You need the export-data module. It extends a chart with downloadCSV method. function downlaodCsv() { chart.downloadCSV() } live exa ...
  • Trick是调查JSON格式,然后是Data.parse()格式。 文件呃? 还有“Highcharts错误#15: http: //www.highcharts.com/errors/15 highstock.js:13:195”。 我的数据是按日期排序的,还不够好吗? 现在需要将此转换为每个图表的多个csv。 $(function() { var magx = []; $.get('stuff.csv', function(csv1) { var l ...
  • 选项1 有一个插件 ,允许您导出CSV(这是你正在使用的)。 在同一页面上,他们已经展示了如何使用警告框来获取CSV,这是否足够? 直接链接到jsfiddle 选项2 您可以对其进行编码,以便只有特定的菜单项可用 上面的链接 - 您正在寻找“menuItems” 但相反 - 你会: exporting: { buttons: { contextButton: { menuItems: [{ ...
  • Highcharts具有CSV导入方法。 您是否阅读过http://www.highcharts.com/docs/working-with-data/preprocessing-data-from-a-file-csv-xml-json#1 Highcharts has a CSV importing method. Have you read http://www.highcharts.com/docs/working-with-data/preprocessing-data-from-a-file-c ...
  • 啊所以在他们的文档中没有帮助如何做到这一点,但我查看了他们的源代码并发现了这个: /** * Call this on click of 'Download CSV' button */ Highcharts.Chart.prototype.downloadCSV = function () { var csv = this.getCSV(true); getContent( this, 'data:text/csv,\uFEFF' + encodeURI ...
  • 使用setInterval ,将你的ajax放在函数中。 function function1() { //do your AJAX stuff here } setInterval(function1, 300000); //300000 MS == 5 minutes 如果要在加载时显示图形,请使用以下命令: $(window).load(function() { //ajax function here } 参考。 Use setInterval, put your ajax inside ...
  • 您错误地加载数据。 Series对象不负责处理csv数据。 如果使用数据模块 ,则应将数据从系列选项移动到顶级选项,如下所示: data: { // this is how you load the with data module csv: data }, series: [{ ... // here, options for series goes but not data }] 将您的代码与官方示例进行比较: http : //jsfiddle.net/gh/get/l ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)